Skip to content
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

[Search git status] fix extra quotes around paths with space #230

Merged
merged 4 commits into from
Mar 19, 2022

Conversation

PatrickF1
Copy link
Owner

@PatrickF1 PatrickF1 commented Mar 8, 2022

This fixes a bug where file paths outputted by search git status include an extra layer of single quotes if the path includes a space. Turns out this is because we string escape all our paths before writing them to the command line but git status already string escapes paths with spaces.

Fixes #220

@@ -1,5 +1,6 @@
set --global --export SHELL /bin/sh
# don't set FZF_DEFAULT_OPTS so it will set one
# erase FZF_DEFAULT_OPTS so that one will be set by the wrapper function
set --erase FZF_DEFAULT_OPTS
Copy link
Owner Author

Choose a reason for hiding this comment

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

out of scope change to facilitate local tests where I do have a FZF_DEFAULT_OPTS set already

@@ -25,7 +25,7 @@ function _fzf_search_git_status --description "Search the output of git status.
end
end

commandline --current-token --replace -- (string escape -- $cleaned_paths | string join ' ')
Copy link
Owner Author

@PatrickF1 PatrickF1 Mar 19, 2022

Choose a reason for hiding this comment

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

Turns out string escape is unnecessary because git status already escapes filenames with spaces in them

@@ -1,10 +1,11 @@
set files "filename_with_*.txt" "filename with space.csv"
set files "filename_with_*.txt" "filename with space.csv" tests/_resources/nestedfilename
Copy link
Owner Author

Choose a reason for hiding this comment

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

updated test to also test it works for nested filenames

@PatrickF1 PatrickF1 merged commit 2b8e06c into main Mar 19, 2022
@PatrickF1 PatrickF1 deleted the fix-status-files-with-space branch March 19, 2022 18:38
@PatrickF1 PatrickF1 changed the title [Search git status] fix extra quotes from spaced file paths [Search git status] fix extra quotes around paths with space Mar 19, 2022
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.

search git search status doesn’t work for files with spaces
1 participant