From 814b5e96cafb83807ab1d6e3dacebe7fabc01cb1 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 18 Oct 2013 13:23:43 -0400 Subject: 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. --- modules/textadept/editing.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/textadept/editing.lua') 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 -- cgit v1.2.3