Commits

SirAlaran committed e7f618a

Improved behavior of comments code

  • Participants
  • Parent commits 2417778

Comments (0)

Files changed (1)

File comments.lua

 	local line_num = buffer:line_from_position(buffer.current_pos)
 	local prev_line = buffer:get_line(line_num - 1)
 	local curr_line = buffer:get_line(line_num + 1)
-    local prev_is_end = prev_line:find(block_end_pattern.."%s*$")
-    local prev_is_middle = prev_line:find("^%s*"..block_middle_pattern)
-    local curr_is_middle = curr_line:find("^%s*"..block_middle_pattern)
-    local prev_is_start = prev_line:find("^%s*"..block_start_pattern)
+    local prev_is_end = prev_line:find(block_end_pattern.."%s*$") ~= nil
+    local prev_is_middle = prev_line:find("^%s*"..block_middle_pattern) ~= nil
+    local curr_is_middle = curr_line:find("^%s*"..block_middle_pattern) ~= nil
+    local prev_is_start = prev_line:find("^%s*"..block_start_pattern) ~= nil
+	print(prev_is_end, prev_is_middle, curr_is_middle, prev_is_start)
 	if prev_is_end then
 		buffer:null()
 	elseif prev_is_middle or (curr_is_middle and prev_is_start) then
         else
             buffer.line_indentation[line_num] = indent
         end
-		buffer:line_end()
 		return false
 	elseif prev_is_start then
 		local indent = buffer.line_indentation[line_num - 1]
 		if aftercomment ~= nil then
 			buffer:add_text(aftercomment)
 		end
+		p = buffer.current_pos
 		buffer.line_indentation[line_num] = indent
-		buffer:line_end()
+		buffer:goto_pos(p)
 		return false
 	else
 		return true