mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 16:16:28 -04:00
The focused main view always showed a selection while it held focus, even when
its content was a placeholder ("No changed files", a merge-conflict message)
rather than a diff — so pressing a navigation key conjured a highlighted line
over "No changed files", and discarding the last change (or changes vanishing
outside lazygit) left a stale selection behind.
A selection should only show when there are change lines to act on. Two
moments establish or change the content:
- Focus: showInitialDiffSelection now leaves the selection off when the view
has no change lines (ViewHasChangeLines), rather than highlighting a stray
line at the top.
- Render: the side panel's render-to-main is where it decides between a diff
and a placeholder, so that's where the selection's visibility is set —
updateFocusedMainViewSelectionVisibility shows it only on the focused pane
and only when a diff is being rendered. This covers the refresh cases that
focus can't: discarding the last change, and changes disappearing or
reappearing outside lazygit, all hide or restore the selection on the next
refresh. (Focusing reuses the already-rendered content rather than
re-rendering, which is why focus needs its own check.)
Wired into the files panel, where placeholders occur; the commit panels always
render a diff. Adds a SelectionIsShown/SelectionIsHidden test assertion.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| alert_driver.go | ||
| assertion_helper.go | ||
| commit_description_panel_driver.go | ||
| commit_message_panel_driver.go | ||
| common.go | ||
| confirmation_driver.go | ||
| env.go | ||
| file_system.go | ||
| git.go | ||
| int_matcher.go | ||
| matcher.go | ||
| menu_driver.go | ||
| paths.go | ||
| popup.go | ||
| prompt_driver.go | ||
| random.go | ||
| runner.go | ||
| search_driver.go | ||
| shell.go | ||
| test.go | ||
| test_driver.go | ||
| test_test.go | ||
| text_matcher.go | ||
| view_driver.go | ||
| views.go | ||