flow: Preserve trailing newline in selection
This commit is contained in:
parent
f23876f07b
commit
dc014174fd
@ -52,11 +52,12 @@ function flow(bufferPane, align)
|
|||||||
send = buffer.Loc(send.X, send.Y)
|
send = buffer.Loc(send.X, send.Y)
|
||||||
|
|
||||||
local selection = util.String(cursor:GetSelection())
|
local selection = util.String(cursor:GetSelection())
|
||||||
selection = reflow(selection, align, colorColumn())
|
bufferPane.Buf:Replace(sstart, send, reflow(selection, align, colorColumn()))
|
||||||
bufferPane.Buf:Replace(sstart, send, selection)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function reflow(text, alignment, columns)
|
function reflow(text, alignment, columns)
|
||||||
|
local trailingBreak = text:sub(#text, #text) == "\n"
|
||||||
|
|
||||||
-- get indentation information
|
-- get indentation information
|
||||||
local firstLineIndent, middleLineIndent, inputLines = splitIndentation(text)
|
local firstLineIndent, middleLineIndent, inputLines = splitIndentation(text)
|
||||||
firstLineIndent = firstLineIndent or ""
|
firstLineIndent = firstLineIndent or ""
|
||||||
@ -102,6 +103,7 @@ function reflow(text, alignment, columns)
|
|||||||
end
|
end
|
||||||
addLine()
|
addLine()
|
||||||
|
|
||||||
|
if trailingBreak then result = result .. "\n" end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user