diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-14 09:50:52 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-19 10:47:21 +1100 |
commit | 54bd94ad24ca24ca12fab59e9dbf0d79fe7681da (patch) | |
tree | 0dd7c0819d29aa38828486f3e5c6b0a017790c5b /pkg/gui/types | |
parent | 8840c1a2b75749724b2dc6e329c2e150db93bc5a (diff) |
Add SetSelection function for list contexts and use it in most places
The only time we should call SetSelectedLineIdx is when we are happy for a
select range to be retained which means things like moving the selected line
index to top top/bottom or up/down a page as the user navigates.
But in every other case we should now call SetSelection because that will
set the selected index and cancel the range which is almost always what we
want.
Diffstat (limited to 'pkg/gui/types')
-rw-r--r-- | pkg/gui/types/context.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index b20d70beb..3557cf5aa 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -224,6 +224,7 @@ type IList interface { type IListCursor interface { GetSelectedLineIdx() int SetSelectedLineIdx(value int) + SetSelection(value int) MoveSelectedLine(delta int) ClampSelection() CancelRangeSelect() @@ -236,6 +237,7 @@ type IListCursor interface { type IListPanelState interface { SetSelectedLineIdx(int) + SetSelection(int) GetSelectedLineIdx() int } |