fix(setqflist): don't strip trailing newline from working tree state #879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The fix of #779 in #862 broke
setqflist
. An empty hunk is being added to the quickfix for each changed file and no hunks is being added for a newline appended to a file.Problem
Repo:get_show_text
is used to retrieve the lines of the index state andutils.file_lines
is used to retrieve the lines of the working tree state. The trailing empty line is being retained byRepo:get_show_text
(by providing{ raw = true }
to Repo:command)gitsigns.nvim/lua/gitsigns/git.lua
Lines 404 to 405 in 907ae86
utils.file_lines
gitsigns.nvim/lua/gitsigns/util.lua
Lines 29 to 35 in 907ae86
io.lines
strips trailing newlines by default).This PR fixes the problem by adding the option to retain the trailing empty line to
utils.file_lines
as well. I can see that this method is only used bybuildqflist
at the moment so we could just make this the default behaviour but:Repo:command
which strips the trailing empty line by default.Reproduction of bug and fix
foo
has had a trailing new line appended as in Newline at end of file is not shown #779 andbar
has had its first line modified.