diff --git a/flow/go.lua b/flow/go.lua index 862cbf1..75ccbd0 100644 --- a/flow/go.lua +++ b/flow/go.lua @@ -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