Skip to content

Searchwd #344#353

Open
vds2212 wants to merge 4 commits intodyng:masterfrom
vds2212:searchwd
Open

Searchwd #344#353
vds2212 wants to merge 4 commits intodyng:masterfrom
vds2212:searchwd

Conversation

@vds2212
Copy link
Copy Markdown
Contributor

@vds2212 vds2212 commented Apr 29, 2026

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.

@dyng
Copy link
Copy Markdown
Owner

dyng commented May 2, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread autoload/ctrlsf.vim
let target_winnr = ctrlsf#win#FindTargetWindow(a:file)
if target_winnr == 0
exec 'silent split ' . fnameescape(a:file)
exec 'silent split ' . fnameescape(file_path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread autoload/ctrlsf/backend.vim Outdated
" BuildCommand()
"
func! s:BuildCommand(args, for_shell) abort
let g:ctrlsf_pwd = getcwd()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I have adapted the code and redone my testing.

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.

2 participants