From 54bd94ad24ca24ca12fab59e9dbf0d79fe7681da Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 14 Jan 2024 09:50:52 +1100 Subject: 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. --- pkg/gui/controllers/tags_controller.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkg/gui/controllers/tags_controller.go') diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index dcbef4d2c..e96dde2e4 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -210,7 +210,9 @@ func (self *TagsController) createResetMenu(tag *models.Tag) error { func (self *TagsController) create() error { // leaving commit SHA blank so that we're just creating the tag for the current commit - return self.c.Helpers().Tags.OpenCreateTagPrompt("", func() { self.context().SetSelectedLineIdx(0) }) + return self.c.Helpers().Tags.OpenCreateTagPrompt("", func() { + self.context().SetSelection(0) + }) } func (self *TagsController) withSelectedTag(f func(tag *models.Tag) error) func() error { -- cgit v1.2.3