jesseduffield.lazygit/pkg/gui/context
Stefan Haller 4e441127f3 Clear highlight in HandleFocusLost
Remove the old mechanism of clearing the highlight in Layout.

This fixes a problem with a wrong highlight showing up in the staging panel when
entering a file with only staged changes.

Reproduction recipe:
1. stage all changes in a file by pressing space on it in the files panel
2. enter the staged changes panel by pressing enter
3. unstage one of the changes
This makes the unstaged changes panel visible, but keeps the focus in the staged
changes panel. However, the highlight in the unstaged changes view becomes
visible, as if it were focused.

To explain why this happens, you need to know how the selection highlighting of
a view is turned on or off. It is turned on when it gains the focus, i.e. when
ActivateFocus is called on it, which in turn happens when PushContext is called.
It is turned off in Layout when gocui sees that the current view is no longer
the same as last time, in which case it calls onViewFocusLost on the previous
current view.

This mechanism only works reliably when there is at most one PushContext call
per event handler. If there is more than one, then the first one gets its
highlight turned on, then the second one, but since gocui has never seen the
first one as the active view in Layout, it doesn't get the highlight turned off
again even though it should.

And this happens in the above scenario. When pressing enter on a file with only
staged changes, we first push the staging context (in
FilesController.EnterFile), and then later we push the stagingSecondary context
when we realize we only have staged changes. This leaves the highlight of the
staging context on.
2024-06-23 13:21:49 +02:00
..
traits Set mode to none when calling SetSelectionRangeAndMode with empty non-sticky range 2024-03-16 22:01:13 +01:00
base_context.go Rerender fewer views when their width changes 2024-06-23 13:10:48 +02:00
branches_context.go Rerender fewer views when their width changes 2024-06-23 13:10:48 +02:00
commit_files_context.go Use model searching in commits (and sub-commits) view 2024-06-23 11:43:12 +02:00
commit_message_context.go Always show the "Press <c-o> to open menu" help text in the commit panel 2024-03-18 20:44:03 +01:00
confirmation_context.go split context common from helper common 2023-04-30 13:19:53 +10:00
context.go Layout the bottom line view using spacer views 2023-12-09 11:18:28 +01:00
context_common.go split context common from helper common 2023-04-30 13:19:53 +10:00
dynamic_title_builder.go show namesake for child views 2022-03-26 18:00:46 +11:00
filtered_list.go Get rid of the retain-sort-order-when-filtering logic again 2024-03-17 12:23:07 +01:00
filtered_list_view_model.go Get rid of the retain-sort-order-when-filtering logic again 2024-03-17 12:23:07 +01:00
history_trait.go Add search history 2023-09-20 08:35:41 +03:00
list_context_trait.go Render the view when scrolling with the wheel 2024-06-23 11:54:21 +02:00
list_renderer.go Use model searching in commits (and sub-commits) view 2024-06-23 11:43:12 +02:00
list_renderer_test.go Set groundwork for better disabled reasons with range select 2024-01-23 13:03:37 +11:00
list_view_model.go Reduce the chance of race condition with list cursor 2024-01-28 09:20:52 +11:00
local_commits_context.go Rerender fewer views when their width changes 2024-06-23 13:10:48 +02:00
menu_context.go Support showing checkboxes or radio buttons in menus 2024-06-23 12:53:15 +02:00
merge_conflicts_context.go Standardise display of range selection across views 2024-01-19 10:47:21 +11:00
parent_context_mgr.go refactor contexts code 2022-03-17 19:13:40 +11:00
patch_explorer_context.go Use model searching in commits (and sub-commits) view 2024-06-23 11:43:12 +02:00
reflog_commits_context.go Rerender fewer views when their width changes 2024-06-23 13:10:48 +02:00
remote_branches_context.go Don't redraw remote branches view when its width changes 2024-06-23 13:08:01 +02:00
remotes_context.go Add SpinnerConfig 2024-04-06 13:46:15 +02:00
search_trait.go Don't select current search result when showing search status 2023-09-25 16:37:59 +10:00
setup.go Layout the bottom line view using spacer views 2023-12-09 11:18:28 +01:00
simple_context.go Clear highlight in HandleFocusLost 2024-06-23 13:21:49 +02:00
stash_context.go Get rid of the retain-sort-order-when-filtering logic again 2024-03-17 12:23:07 +01:00
sub_commits_context.go Rerender fewer views when their width changes 2024-06-23 13:10:48 +02:00
submodules_context.go Get rid of the retain-sort-order-when-filtering logic again 2024-03-17 12:23:07 +01:00
suggestions_context.go Allow editing a custom command from the suggestions list by pressing 'e' 2024-05-19 07:06:18 +02:00
tags_context.go Add SpinnerConfig 2024-04-06 13:46:15 +02:00
view_trait.go Only render visible portion of the screen for commits view 2024-06-23 11:54:21 +02:00
working_tree_context.go Use model searching in commits (and sub-commits) view 2024-06-23 11:43:12 +02:00
worktrees_context.go Get rid of the retain-sort-order-when-filtering logic again 2024-03-17 12:23:07 +01:00