Skip to content

Commit

Permalink
Keep the trailing newline to avoid undo/redo jankiness
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt committed Sep 5, 2016
1 parent e0e9b15 commit 426bf75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/hlint-refactor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ module.exports = Refactor =
buffer =atom.workspace.getActiveTextEditor()
pos = buffer.getCursorBufferPosition()
hlintPath =atom.config.get 'hlint-refactor.hlintPath'
hasTrailingNewline = buffer.getText().endsWith("\n")
@runCmd(hlintPath,['-'].concat(os),buffer.getText(), "hlint-refact")
.then (res) =>
if res.exitCode == 0
buffer.getBuffer().setTextViaDiff(res.text)
buffer.getBuffer().setTextViaDiff(if hasTrailingNewline then res.text + "\n" else res.text)
buffer.setCursorBufferPosition(pos)
else
atom.notifications.addError(res.text)

0 comments on commit 426bf75

Please sign in to comment.