Improved behaviour of doc:join-lines when joining to empty line
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user