Skip to content

Auto-select first file for DiffView, whenever context is set or changed #1019

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

Closed
goran-w opened this issue Feb 24, 2025 · 4 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@goran-w
Copy link
Contributor

goran-w commented Feb 24, 2025

There is an unnecessary click whenever the "Select file to view changes" (DiffView) panel is/becomes visible and/or the selected context is changed.

It would be much preferable to always auto-select the first file (diff) from the list (whenever there is no active selection already), both on entering/activating the diff panel and when changing its selected context. (NOTE: This means the Text.Diff.Welcome string should be changed from "Select file to view changes" to "No changes available" or similar, since it would only be shown if the file list is empty.)

This sort of auto-selection is what we're used to from other tools (Plastic SCM, GitHub Desktop, Fork, Git Extensions, Tower, Sourcetree etc).

All the 5 DiffView instances would benefit from auto-selection:

  • On the CHANGES tab-link-page in HISTORY view.
  • On the RevisionCompare page in HISTORY view (i.e when exactly 2 commits are multi-selected).
  • In the LOCAL CHANGES view - auto-select from non-empty list of UNSTAGED or STAGED (in whatever order would make more sense).
  • In the STASHES view, when changing the selected stash. (NOTE: Should also auto-select the first stash when entering!)
  • In the "Branch Compare" window.

Related:
When going back from multi-selection to single-selection in HISTORY view, the previously active tab-link-page (INFORMATION / CHANGES / FILES) should be preserved, instead of reverting to the first tab-link-page (INFORMATION) !

@goran-w goran-w changed the title [Enhancement] Auto-select first changed file in list, whenever selecting a commit or local changes [Enhancement] Auto-select first file for DiffView, whenever context is set or changed Feb 24, 2025
@love-linger
Copy link
Collaborator

See issue #261 and discussion #754

@goran-w
Copy link
Contributor Author

goran-w commented Feb 24, 2025

Thanks, I contributed to the discussion in #754. This feature is oft-requested and could be implemented as an optional one (via Preferences).

@goran-w
Copy link
Contributor Author

goran-w commented Feb 25, 2025

Awesome, thanks a lot! 🥳

Comments after testing:

  • The first file-change is now auto-selected on CHANGES page when changing selected commit in HISTORY view (and RevisionCompare when selecting 2 commits), in STASHES view when changing selected Stash, and finally when choosing "Compare with HEAD/Worktree" on a branch/commit. This is perfect! 👍
  • I realize now that the LOCAL CHANGES view already remembers its currently selected Unstaged/Staged file-change (after initial selection). Likewise, the STASHES view already remembers its current Stash (after initial selection). These are remembered per each repo-tab in the current session, so with your current fix (for auto-selection on Stash change) it now works great! (I don't mind so much an extra click on session startup, it was primarily the repeated extra clicks within an ongoing session that bothered me.)
  • The selected details page (INFORMATION / CHANGES / FILES) is now remembered per repo-tab (in current session), even after switching between single-/pair-/multi-selection in the graph/log. Excellent! 🎉
  • (The Text.Diff.Welcome string does not need to be changed (as I first suggested), it still works fine even if the list of file-changes are empty.)
  • I consider this ticket Completed. 😉

@goran-w
Copy link
Contributor Author

goran-w commented Feb 25, 2025

(And the way this is implemented, it could easily be made an optional (by Preference) feature, if desired, in a future update.) 👍

@goran-w goran-w changed the title [Enhancement] Auto-select first file for DiffView, whenever context is set or changed Auto-select first file for DiffView, whenever context is set or changed Feb 25, 2025
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

2 participants