jesseduffield / lazygit

simple terminal UI for git commands
MIT License
48.05k stars 1.73k forks source link

Search the model instead of the view in the commits panel #3642

Closed stefanhaller closed 1 week ago

stefanhaller commented 4 weeks ago

This makes it possible to search the model data instead of the view when pressing /, and uses this for the commits view.

This is mainly a preparation for #2533 which requires it, but it is also useful on its own, because it makes it possible to search for full commit hashes. It will highlight the abbreviated hash in that case.

codacy-production[bot] commented 4 weeks ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 3af545daf7cf6458e8efd324012047ce688f08e6[^1] :white_check_mark: 97.53%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (3af545daf7cf6458e8efd324012047ce688f08e6) | Report Missing | Report Missing | Report Missing | | | Head commit (6a6316cfb632a28627e067c8a4d30786acffee38) | 52115 | 45077 | 86.50% | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#3642) | 81 | 79 | **97.53%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences


:rocket: Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more [^1]: Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

jesseduffield commented 3 weeks ago

Great work! Two things from testing it locally: 1) If I open lazygit and go straight to searching the commits view and typing in my search value I sometimes (50% of the time) end up with 'no matches shown' where my cursor is, before I've pressed enter.

image

2) What are your thoughts on greying out the non-matched lines to better highlight the matching lines?

image

I've got a hacky commit to implement that. Let me know if you'd like to see it

stefanhaller commented 3 weeks ago
  1. If I open lazygit and go straight to searching the commits view and typing in my search value I sometimes (50% of the time) end up with 'no matches shown' where my cursor is, before I've pressed enter.

That's because of the newly added ReapplySearch that we do every time the model changes. I was simply calling Search again there, which is not a good idea; I had to split this up into two separate functions. See 3da6594a433e and d04cb9a7c583. It's probably easier to review after squashing the fixups, let me know if you want me to do that now.

  1. What are your thoughts on greying out the non-matched lines to better highlight the matching lines? I've got a hacky commit to implement that. Let me know if you'd like to see it

I like the idea, and would be interested to see your commit. It sounds unrelated to this PR though, I think we should do that separately afterwards.