Skip to content

fix(on_output_parse): resolve relative paths against task cwd, not vim's real cwd - #524

Open
dwf wants to merge 1 commit into
stevearc:masterfrom
dwf:fix/on-output-parse-relative-file-root
Open

fix(on_output_parse): resolve relative paths against task cwd, not vim's real cwd#524
dwf wants to merge 1 commit into
stevearc:masterfrom
dwf:fix/on-output-parse-relative-file-root

Conversation

@dwf

@dwf dwf commented Jul 16, 2026

Copy link
Copy Markdown

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

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

bug: on_output_parse resolves relative diagnostic paths against Neovim's real cwd, not task.cwd/relative_file_root

1 participant