Improved behaviour of `doc:join-lines` when joining to empty line
This commit is contained in:
parent
878c94a334
commit
de5cb4fa52
|
@ -160,7 +160,9 @@ local commands = {
|
||||||
local line1, _, line2 = doc():get_selection(true)
|
local line1, _, line2 = doc():get_selection(true)
|
||||||
if line1 == line2 then line2 = line2 + 1 end
|
if line1 == line2 then line2 = line2 + 1 end
|
||||||
local text = doc():get_text(line1, 1, line2, math.huge)
|
local text = doc():get_text(line1, 1, line2, math.huge)
|
||||||
text = text:gsub("\n[\t ]*", " ")
|
text = text:gsub("(.-)\n[\t ]*", function(x)
|
||||||
|
return x:find("^%s*$") and x or x .. " "
|
||||||
|
end)
|
||||||
doc():insert(line1, 1, text)
|
doc():insert(line1, 1, text)
|
||||||
doc():remove(line1, #text + 1, line2, math.huge)
|
doc():remove(line1, #text + 1, line2, math.huge)
|
||||||
if doc():has_selection() then
|
if doc():has_selection() then
|
||||||
|
|
Loading…
Reference in New Issue