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

Change default delimiter #915

Closed
wants to merge 1 commit into from

Conversation

kit494way
Copy link
Contributor

Currently, the default delimiter is two or more white space characters.
The default delimiter should be one or more white space characters.

@denisidoro
Copy link
Owner

Won't this break commands with a single space?

@kit494way
Copy link
Contributor Author

kit494way commented Sep 26, 2024

After re-reading the code, I realized that this change could affect more than just the intended part.
My intention is to omit redundant --delimiter options for variables.
My use cases are here.

% gh

# download release asset
gh release download <release_tag> -R <release_repo> -p <asset_pattern>

$ release_tag: gh release list -R <release_repo> --exclude-pre-releases --exclude-drafts --json tagName,publishedAt --jq '.[] | [.tagName, .publishedAt] | @tsv' --- --column 1 --delimiter '\t'
$ asset_pattern: gh release view -R <release_repo> --json assets --jq '.assets[].name'
% mise

# use local
mise use <tool>@<version>

$ tool: mise plugins ls -c --user -q
$ version: join -a 1 <(mise ls-remote <tool> | sort) <(mise ls -i <tool> | awk '{print $2 "\t*"}' | sort) | sort -k 1 -Vr --- --column 1 --delimiter "\s+"

The first time I tried to use the --column option without the --delimiter, I was confused.
This is because I expected the default delimiter to be something like \s+.
In my opinion, \s+ is more common than \s\s+ as the delimiter.
Currently, when I use the --column option, I always specify the --delimiter, which I find redundant.

After reconsideration, I think the following change would better fit the intent of changing the default delimiter for variables.

diff --git a/src/finder/structures.rs b/src/finder/structures.rs
index a055194..231ff06 100644
--- a/src/finder/structures.rs
+++ b/src/finder/structures.rs
@@ -66,6 +66,7 @@ impl Opts {
             overrides: CONFIG.fzf_overrides_var(),
             suggestion_type: SuggestionType::SingleRecommendation,
             prevent_select1: false,
+            delimiter: Some(r"\s+".to_string()),
             ..Default::default()
         }
     }

change here

Is this OK?

@alexis-opolka
Copy link
Collaborator

@denisidoro @kit494way Is this PR still open to be merged? Or is there any change still pending?

@denisidoro
Copy link
Owner

I'm afraid of the (potentially undesired) consequences of this change.

If there's evidence it's a safe change, I can approve it.

@kit494way
Copy link
Contributor Author

In the case of selecting a column that contains a single space without specifying a delimiter, this change will change the behavior.
I don't know if there is a specific case for that.

Instead of changing the default delimiter, can you approve a change that allows the default delimiter to be changed in a configuration file?
If so, I will close this pull request and create a new issue.

@alexis-opolka
Copy link
Collaborator

@kit494way I think it is the best approach considering the possible consequences of changing the default behaviour of navi.
It seems denisidoro also agrees with creating a new configuration variable and make it a kind of opt-in behaviour for the users.

Let me know when your changes are to be merged into the main branch as I will take this opportunity to update the documentation on this new configuration variable in the same PR.

Good luck!

@kit494way
Copy link
Contributor Author

I opened a new issue #940 .

@kit494way kit494way closed this Feb 6, 2025
@kit494way kit494way deleted the fix-default-delimiter branch February 6, 2025 14:42
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.

3 participants