fix(on_output_parse): resolve relative paths against task cwd, not vim's real cwd - #524
Open
dwf wants to merge 1 commit into
Open
fix(on_output_parse): resolve relative paths against task cwd, not vim's real cwd#524dwf wants to merge 1 commit into
dwf wants to merge 1 commit into
Conversation
…m's real cwd vim.fn.getqflist() resolves any %f-matched relative filename into a buffer immediately, against Neovim's actual getcwd() at the time it's called. The errorformat-based parser (parselib.parser_from_errorformat) never scoped this call to task.cwd/relative_file_root, so relative diagnostic paths were silently resolved against whatever Neovim's real cwd happened to be, rather than the task's cwd or a configured relative_file_root override. fix_relative_filenames only rewrites a plain diag.filename string, which errorformat-parsed items never have (they carry bufnr instead), so it never caught this case either. Wrap the parser:parse()/parser:get_result() calls in util.run_in_cwd(), mirroring the existing pattern already used for the same getqflist() call in on_output_quickfix.lua. Regression test in tests/component/on_output_parse_spec.lua fails against the prior behavior (path resolves to vim's real cwd) and passes with this fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
vim.fn.getqflist() resolves any %f-matched relative filename into a buffer immediately, against Neovim's actual getcwd() at the time it's called. The errorformat-based parser (parselib.parser_from_errorformat) never scoped this call to task.cwd/relative_file_root, so relative diagnostic paths were silently resolved against whatever Neovim's real cwd happened to be, rather than the task's cwd or a configured relative_file_root override.
fix_relative_filenames only rewrites a plain diag.filename string, which errorformat-parsed items never have (they carry bufnr instead), so it never caught this case either.
Wrap the parser:parse()/parser:get_result() calls in util.run_in_cwd(), mirroring the existing pattern already used for the same getqflist() call in on_output_quickfix.lua.
Regression test in tests/component/on_output_parse_spec.lua fails against the prior behavior (path resolves to vim's real cwd) and passes with this fix.
Fixes #523