Set proper current directory for :lmake with 'cargo' compiler #525
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.
The buffer-local current directory of the location-list window should match the location of the Cargo.toml file.
Related commit: c6ffafc Related issue: #230
This commit fixes the following bug; cargo#quickfix#CmdPre() and cargo#quickfix#CmdPost() are not called when executing :lmake, and hence filenames in the location list are not parsed correctly.
Steps to reproduce the bug:
Open
main.rs
and execute:lmake check
. (Press ENTER if necessary.)Expected behavior: The cursor jumps to the last line in
example/src/main.rs
.Actual behavior: The cursor jumps to the top of the wrong file, i.e.,
example/src/src/main.rs
.Explanation: This is related to the known and fixed issue #230. Since the error message of cargo is relative to the project root, we have to take care of the current directory of the window when parsing the file names in the error message. The commit
c6ffafc fixes by executing :chdir before and after the execution of :make. But they don't cover the case for :lmake. This commit fixes this case.
I want to mention another solution (cause?) to this bug: Since this is an error about a filename resolution, it is natural to use the "%D" and "%X" code in the 'errorformat' option (:help E379), which also prevents potential bugs coming from the hook to the DirChanged event, e.g. showing the result of :!ls everytime the current directory changes. But I think our solution is practically OK. (And above all, I am scared of touching an existing errorformat and breaking anything.)