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

Add fuzzy-finder for project switching #4317

Merged
merged 3 commits into from
Sep 13, 2023
Merged

Add fuzzy-finder for project switching #4317

merged 3 commits into from
Sep 13, 2023

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Sep 8, 2023

switch-fzf

Overview

Adds fuzzy-finder for switch without any arguments which lists all project/branch pairs for you to search, whatever you select will be switched to.

Implementation notes

  • Make the project-branch optional for switch, if it's Nothing, trigger a fuzzy-find to fill it in.
  • Adds a new query to fetch ALL project/branch pairs. fzf is killer fast, so should have no problem handling thousands of branches if it comes to that.

Interesting/controversial decisions

Should it search projects, then search branches instead?

Test coverage

None

@ChrisPenner ChrisPenner marked this pull request as ready for review September 8, 2023 22:58
@ceedubs
Copy link
Contributor

ceedubs commented Sep 11, 2023

@ChrisPenner nice! I will definitely be using this.

Would it be much effort and/or desirable to put the current project at the beginning (or end? Which is it?) of the list? My thought was that I'm often switching between /main and a /my-feature-branch and I might just type switch and then hit the up button. Maybe bonus points for taking the recency of visiting a branch into account, but that's getting fancy 😄.

@@ -230,7 +230,7 @@ data Input
| DiffNamespaceToPatchI DiffNamespaceToPatchInput
| ProjectCreateI Bool {- try downloading base? -} (Maybe ProjectName)
| ProjectRenameI ProjectName
| ProjectSwitchI ProjectAndBranchNames
| ProjectSwitchI (Maybe ProjectAndBranchNames {- Nothing triggers fuzzy-finder -})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| ProjectSwitchI (Maybe ProjectAndBranchNames {- Nothing triggers fuzzy-finder -})
| ProjectSwitchI (Maybe ProjectAndBranchNames {- `Nothing` triggers fuzzy-finder -})

Comment on lines +689 to +708
P.wrapColumn2
[ ( P.sep
" "
[ backtick (P.sep " " [P.string cmd, "foo"]),
"removes the",
P.string target,
"name `foo` from the namespace."
],
""
),
( P.sep
" "
[ backtick (P.sep " " [P.string cmd, "foo bar"]),
"removes the",
P.string target,
"name `foo` and `bar` from the namespace."
],
""
)
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Delayed ormolu?

@aryairani
Copy link
Contributor

Has a merge conflict now but otherwise looks good 😬

@ChrisPenner ChrisPenner self-assigned this Sep 13, 2023
@ChrisPenner
Copy link
Contributor Author

@ceedubs Okay I put the active project at the bottom :) I'll leave sorting by "frecency" for another day

@ChrisPenner ChrisPenner added the ready-to-merge Apply this to a PR and it will get merged automatically once CI passes and 1 reviewer has approved label Sep 13, 2023
@mergify mergify bot merged commit 858919a into trunk Sep 13, 2023
6 checks passed
@mergify mergify bot deleted the cp/switch-fzf branch September 13, 2023 19:32
@mergify mergify bot removed the ready-to-merge Apply this to a PR and it will get merged automatically once CI passes and 1 reviewer has approved label Sep 13, 2023
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