Skip to content

Set proper current directory for :lmake with 'cargo' compiler #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yutayamamoto
Copy link

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:

cargo new example
cd example/src
echo erroneous_line >> main.rs

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.)

The buffer-local current directory of the location-list window should
match the location of the Cargo.toml file.
Related commit: c6ffafc
Related issue: rust-lang#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:
```
cargo new example
cd example/src
echo erroneous_line >> main.rs
```
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 rust-lang#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant