Searchwd #344#353
Conversation
…rrent working directory (that could have change in the meantime)
…of the CtrlSF buffer.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fde0210526
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let target_winnr = ctrlsf#win#FindTargetWindow(a:file) | ||
| if target_winnr == 0 | ||
| exec 'silent split ' . fnameescape(a:file) | ||
| exec 'silent split ' . fnameescape(file_path) |
There was a problem hiding this comment.
Canonicalize window lookup with the same path you open
This change opens buffers using file_path (often absolute) but s:OpenFileInWindow() still identifies existing targets with the original a:file value. When search results are relative (default), the first jump opens an absolute buffer name and subsequent jumps can no longer match that buffer by a:file, so CtrlSF may reopen/re-split the same file instead of reusing the current window. The regression is visible by jumping to the same match repeatedly after one search; path matching should use the same canonical form for lookup and open/edit.
Useful? React with 👍 / 👎.
| " BuildCommand() | ||
| " | ||
| func! s:BuildCommand(args, for_shell) abort | ||
| let g:ctrlsf_pwd = getcwd() |
There was a problem hiding this comment.
You need to verify the scope of the g:ctrlsf_pwd variable. I think this variable should remain constant whenever the ctrlsf command is invoked; therefore, it would be more appropriate to assign it within s:ExecSearch. Since s:BuildCommand is intended as a utility function, it shouldn't be responsible for this assignment.
There was a problem hiding this comment.
You are right. I have adapted the code and redone my testing.
…earch since it is more sensible and robust.
Dear CtrlSF,
Here is a pull request that solve issue #344 (make sure CtrlSF is not get lost when the working directory has changed since the original search request).
Note: I have a plugin (vim-rooter) that change the working directory when visiting files.
According to your suggestion I have adapted the original pull request to support also the edition of the buffers.
Kind regards,
Vivian.