From f23cb33f7cbe134db04be292a00cfb47bcce609e Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 7 Feb 2022 19:22:43 +0100 Subject: [PATCH] Ignore empty lines in `line_comment` --- data/core/commands/doc.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index d53e3638..2125e185 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -105,18 +105,20 @@ local function line_comment(comment, line1, col1, line2, col2) for line = line1, line2 do local text = doc().lines[line] local s = text:find("%S") - local cs, ce = text:find(start_comment, s, true) - if s and cs ~= s then - uncomment = false + if s then + local cs, ce = text:find(start_comment, s, true) + if cs ~= s then + uncomment = false + end + start_offset = math.min(start_offset, s) end - start_offset = math.min(start_offset, s) end - + local end_line = col2 == #doc().lines[line2] for line = line1, line2 do local text = doc().lines[line] local s = text:find("%S") - if uncomment then + if s and uncomment then if end_comment and text:sub(#text - #end_comment, #text - 1) == end_comment then doc():remove(line, #text - #end_comment, line, #text) end