From 91761117c5f7ead56c212c9795ece35dcaadcb24 Mon Sep 17 00:00:00 2001 From: Georgi Kirilov <> Date: Sat, 31 Oct 2020 11:50:52 +0200 Subject: [PATCH] do not refmt when deleting empty range --- edit.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/edit.lua b/edit.lua index fc3747a..9986407 100644 --- a/edit.lua +++ b/edit.lua @@ -243,6 +243,8 @@ function M.new(parser, walker, fmt, write, delete, eol_at) end local function pick_out(range, pos, action) + local ndeleted = 0 + if range.start == range.finish then return ndeleted end local sexps = parser.tree local skips = sexps.unbalanced_delimiters(range) -- handle splice and kill-splice of forms and strings: @@ -264,7 +266,7 @@ function M.new(parser, walker, fmt, write, delete, eol_at) table.sort(skips, function(a, b) return a.start < b.start end) table.insert(skips, {start = range.finish - (drop_eol and 1 or 0)}) table.insert(skips, 1, {finish = range.start}) - local ndeleted = drop_eol and 1 or 0 + ndeleted = ndeleted + (drop_eol and 1 or 0) for i = #skips - 1, 1, -1 do local region = {start = skips[i].finish, finish = skips[i + 1].start} if skips[i].closing and skips[i + 1].opening then -- 2.11.4.GIT