mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 08:06:25 -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>
|
||
|---|---|---|
| .. | ||
| context | ||
| controllers | ||
| filetree | ||
| mergeconflicts | ||
| modes | ||
| patch_exploring | ||
| popup | ||
| presentation | ||
| services/custom_commands | ||
| status | ||
| style | ||
| types | ||
| background.go | ||
| command_log_panel.go | ||
| context.go | ||
| context_config.go | ||
| controllers.go | ||
| dummies.go | ||
| editors.go | ||
| extras_panel.go | ||
| global_handlers.go | ||
| gui.go | ||
| gui_common.go | ||
| gui_driver.go | ||
| information_panel.go | ||
| keybindings.go | ||
| layout.go | ||
| main_panels.go | ||
| menu_panel.go | ||
| options_map.go | ||
| pty.go | ||
| pty_test.go | ||
| recent_repos_panel.go | ||
| side_panels.go | ||
| side_panels_test.go | ||
| tasks_adapter.go | ||
| tasks_adapter_test.go | ||
| test_mode.go | ||
| test_timeout_norace.go | ||
| test_timeout_race.go | ||
| view_helpers.go | ||
| views.go | ||