Skip to content

Use the working folder of the search to used it to open the result file. #345

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 2 commits into
base: master
Choose a base branch
from

Conversation

vds2212
Copy link
Contributor

@vds2212 vds2212 commented Feb 11, 2025

This pull request intent to solve issue #344:

Fail to open the file of the search result when the working directory change

@dyng
Copy link
Owner

dyng commented Apr 15, 2025

I think you should use g:ctrlsf_absolute_file_path option instead. This option was originally added to address the issue of potential changes in the working directory.

@vds2212
Copy link
Contributor Author

vds2212 commented Apr 15, 2025

It is indeed a solution but when your project is in a deep file structure the output of CtrlSF is clutter with the path prefix that add no value to the user.

I believe the pull request bring something to some users (;-))

@@ -83,6 +83,7 @@ let s:backend_args_map = {
" BuildCommand()
"
func! s:BuildCommand(args, for_shell) abort
let g:ctrlsf_pwd = getcwd()
Copy link
Owner

Choose a reason for hiding this comment

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

Avoid using global variables as they're typically reserved for options. Instead, define it as s:current_pwd (similar to s:current_mode), and add a new public method ctrlsf#GetFilePath(path).

@@ -426,21 +426,28 @@ func! s:OpenFileInWindow(file, lnum, col, mode, split) abort
endif
endif

let file_path = ''
Copy link
Owner

Choose a reason for hiding this comment

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

Have you verified that ctrlsf#edit#Save still works correctly when the CWD changes? I suspect there might be issues with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review.
I'll do more tests and I'll come back to you.

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