jesseduffield.lazygit/pkg
Stefan Haller 252a26cbc4 Hide the focused main view's selection when there's no diff to act on
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>
2026-08-08 12:59:00 +02:00
..
app Recognize a repo that has no work tree instead of bailing out 2026-08-08 11:15:01 +02:00
cheatsheet Render every key for a binding in the cheatsheet 2026-05-25 15:18:18 +02:00
commands Add identity-based line accessors to PatchBuilder 2026-08-08 12:59:00 +02:00
common Move NewDummyCommon to pkg/common 2025-05-06 09:43:26 +02:00
config Replace gui.showSelectionInFocusedMainView config with on-demand selection 2026-08-08 12:58:59 +02:00
constants Adapt links 2026-07-31 08:42:51 +02:00
env Remember how to get back to a repo we entered a submodule from 2026-08-08 11:15:01 +02:00
fakes Modernize all codes 2025-11-15 10:46:23 +01:00
gocui Add an on-demand inclusion gutter to gocui views 2026-08-08 12:59:00 +02:00
gui Hide the focused main view's selection when there's no diff to act on 2026-08-08 12:59:00 +02:00
i18n Navigate the focused main view by file and hunk 2026-08-08 12:58:59 +02:00
integration Hide the focused main view's selection when there's no diff to act on 2026-08-08 12:59:00 +02:00
jsonschema Fold legacy quit-alt1 into the multi-key quit binding 2026-05-25 15:32:47 +02:00
logs Fix Windows linter errors 2026-06-16 16:21:13 +02:00
snake Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00
tasks Scan for the restore target before revealing the new content 2026-08-08 12:58:59 +02:00
theme Copy gocui files into lazygit repo under pkg/gocui 2026-04-30 14:29:08 +02:00
updates Change direct access to Common.UserConfig to a getter 2024-08-18 10:24:52 +02:00
utils Make StringStack generic 2026-08-08 11:15:01 +02:00