aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2013-10-18 13:23:43 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2013-10-18 13:23:43 -0400
commit814b5e96cafb83807ab1d6e3dacebe7fabc01cb1 (patch)
treeb2b0c3d99465364c7f34d506a2662ed9b91e6446
parent84c489b43c0d9796049f77cfd89109196f6d0b3a (diff)
downloadtextadept-814b5e96cafb83807ab1d6e3dacebe7fabc01cb1.tar.gz
textadept-814b5e96cafb83807ab1d6e3dacebe7fabc01cb1.zip
Fixed corner case bug in block uncommenting; modules/textadept/editing.lua
The caret is always constrained to the first line when no selection is present.
-rw-r--r--modules/textadept/editing.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 56b9da66..b92907e8 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -298,7 +298,9 @@ function M.block_comment()
end
buffer:end_undo_action()
anchor, pos = buffer.line_end_position[s] - anchor, buffer.length - pos
- anchor = math.max(anchor, buffer:position_from_line(s)) -- stay on first line
+ -- Keep the anchor and caret on the first line as necessary.
+ local start_pos = buffer:position_from_line(s)
+ anchor, pos = math.max(anchor, start_pos), math.max(pos, start_pos)
if s ~= e then buffer:set_sel(anchor, pos) else buffer:goto_pos(pos) end
end