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)
|
||||
|
||||
local selection = util.String(cursor:GetSelection())
|
||||
selection = reflow(selection, align, colorColumn())
|
||||
bufferPane.Buf:Replace(sstart, send, selection)
|
||||
bufferPane.Buf:Replace(sstart, send, reflow(selection, align, colorColumn()))
|
||||
end
|
||||
|
||||
function reflow(text, alignment, columns)
|
||||
local trailingBreak = text:sub(#text, #text) == "\n"
|
||||
|
||||
-- get indentation information
|
||||
local firstLineIndent, middleLineIndent, inputLines = splitIndentation(text)
|
||||
firstLineIndent = firstLineIndent or ""
|
||||
@ -101,7 +102,8 @@ function reflow(text, alignment, columns)
|
||||
line = line .. token
|
||||
end
|
||||
addLine()
|
||||
|
||||
|
||||
if trailingBreak then result = result .. "\n" end
|
||||
return result
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user