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

Fuzzy search for branches, both local branches and remote branches #2057

Closed
magnusrodseth opened this issue Jul 27, 2022 · 16 comments
Closed
Labels
enhancement New feature or request

Comments

@magnusrodseth
Copy link

magnusrodseth commented Jul 27, 2022

Is your feature request related to a problem? Please describe.

I find myself using quite a lot of time step-by-step iterating through all living remote branches when working in a larger team.

Describe the solution you'd like

I would like to search for branches using fuzzy search. Personally, this is most useful for me regarding remote branches, but I imagine the implementation for local branches is trivial to support after implementing remote branch fuzzy search.

For instance, I want to checkout the remote branch bug/100/fix-something. I want to search when inside the tab for remote branch using / or something, and execute a fuzzy search this way. Typing bug would show me all branches with the string bug in them.

EDIT

After some discussion (see thread), the issue has been re-opened, because this fuzzy-search functionality is not yet implemented. For instance, if I want to find bug/100/fix-something, I'd like to for instance write bugthing. Although this may not be a realistic search, it illustrates the desired fuzzy search functionality. Like @ooloth stated, it would act like fzf or Telescope in Neovim.

Describe alternatives you've considered

The current alternative is nothing. Rather, I manually iterate through all remote branches until I find what I'm looking for.

@magnusrodseth magnusrodseth added the enhancement New feature or request label Jul 27, 2022
@mark2185
Copy link
Collaborator

Was this marked as completed by accident or?

@ooloth
Copy link

ooloth commented Nov 7, 2022

I'd love to see this reopened!

The current non-fuzzy search through remote branches (e.g. when I'm reviewing a PR with a branch name I half remember) doesn't let me be as lazy as I could be if that list gradually narrowed as I type the parts of the branch name I'm confident about (i.e. what happens when you search your combined local/remote branch list in VS Code).

@magnusrodseth
Copy link
Author

magnusrodseth commented Nov 8, 2022

Was this marked as completed by accident or?

@mark2185 @ooloth I closed this manually, as I quickly discovered this functionality was already implemented. At least to the degree I desired.

When I'm in the tab branches, I can simply use / to fuzzy search. For instance, if I know the branch is named fix/100/something, I can simply type / + 100 to find the PR related to the issue ID 100.

Do you agree that the functionality is sufficiently implemented, or is something lacking?

@mark2185
Copy link
Collaborator

mark2185 commented Nov 8, 2022

Do you agree that the functionality is sufficiently implemented, or is something lacking?

It's sufficient for my needs, but @ooloth seems to have different use cases, but I think that calls for a different issue/feature request.

I'm only asking because the issue was opened and then closed 2 minutes after without any explanation so I presumed it might have been a misclick or something. If you're happy with the current implementation, there's no need to do anything else.

@ooloth
Copy link

ooloth commented Nov 8, 2022

I discovered that what I'm asking for is in a WIP stage in PR #1993 (the development of which was live-streamed in this video and this video).

@magnusrodseth When I'm in the branches area and press /, I get what I consider non-fuzzy search functionality (i.e. the search term must match exactly and the branches list does not filter down after each keystroke to show the remaining potential matches). It's a blind search for an exact string that lets me jump through the results afterwards (similar to using / in vim).

That's great, but fuzzy search with filtering would be even lazier (like fuzzy finding git branches in the VS Code command palette or any list using fzf or Telescope in neovim). Since this issue specially requested fuzzy search, I think it's still valid (and connected to the "filtering" concept in the linked PR), but I'd be happy to open a separate issue as @mark2185 suggested if you were just asking for the existing basic search, @magnusrodseth.

@magnusrodseth
Copy link
Author

@ooloth Sounds good.

As I have already written out the desired feature, I'd be happy to re-open this issue, and then someone can work on it 😁

@magnusrodseth magnusrodseth reopened this Nov 9, 2022
@jesseduffield
Copy link
Owner

Apologies for not having made much progress on that WIP in a while. There were some tricky kinks to iron out. I've got a PR on lazydocker (jesseduffield/lazydocker#392) that's close to being merged and my plan is to take the lessons learned from that and apply them in the WIP lazygit PR

@jesseduffield
Copy link
Owner

Although come to think of it, the tricky parts all related to the commits panel. If there isn't a strong use case for fuzzy-searching on the commits panel we could do that as a separate thing later

@ooloth
Copy link

ooloth commented Nov 9, 2022

@jesseduffield No apology needed! These “lazy” tools are great.

For me, searching through local and remote branches is something I do daily (while reviewing PRs), while searching through commits is something I’ve never done.

So launching the feature without commits panel support for now would work for me.

@magnusrodseth
Copy link
Author

@jesseduffield I can +1 on exactly what @ooloth said. Fuzzy searching in branches is a daily thing for me, but I have never had the need to fuzzy-search through commits.

@ooloth
Copy link

ooloth commented Dec 19, 2022

@jesseduffield Apologies! I just discovered c in the Branches pane, which does exactly what I was looking for here: it lets me fuzzy find over the combined list of local and remote branches.

Sorry I missed that! As far as I'm concerned, that satisfies the feature request described in this issue.

Ongoing thanks for lazygit. 🙌

@ooloth
Copy link

ooloth commented Dec 21, 2022

Hmm...I just noticed that we can't use n to create a new local branch when checking out a remote branch in the c window...which has driven me back to searching the Branches > Remotes pane, unfortunately.

Not sure which improvement is quicker and easier to add, but I guess there still isn't a single workflow that allows both fuzzy searching branches and checking them out as local branches.

I wish I knew Go so I could help by opening a PR. 🙃

@karimkhaleel
Copy link
Contributor

@ooloth This could be a temporary workaround for the time being.

customCommands:
  - key: 'C'
    context: 'localBranches'
    command: 'git switch -c $(echo {{ .Form.Branch }} | sed "s/\(.*\/\)\(.*\/\)\(.*\)/\2\3/") {{.Form.Branch }}'
    description: 'Checkout remote branch by name with fuzzy searching'
    prompts:
      - type: 'input'
        title: 'Which branch?'
        key: 'Branch'
        suggestions:
            preset: 'remoteBranches'

@jesseduffield
Copy link
Owner

In the latest release (v0.39.2) we now have exact filtering in the branches panel. But if you want fuzzy filtering, that's added by #2808 (so you'll need to build lazygit from the master branch)

@jesseduffield
Copy link
Owner

@magnusrodseth can you let me know if your issue is now resolved?

@magnusrodseth
Copy link
Author

I am very happy with the current search functionality, so for me, there's no need to keep this open anymore ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants