diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-16 18:25:08 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-16 18:44:39 +1000 |
commit | c8add47fe747449110c802ef1ac23961bc1ec010 (patch) | |
tree | eddcca26717db533f66d180fe9ac51e1970d5928 /pkg/gui | |
parent | 28cd827cea0ff360e6d989055bfdae835ddfcf30 (diff) |
move cursor to right when using auto prefix
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/files_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/view_helpers.go | 28 |
2 files changed, 17 insertions, 13 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index f2e081245..3aff8c3da 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -279,7 +279,7 @@ func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error return gui.createErrorPanel(gui.Tr.SLocalize("SkipHookPrefixNotConfigured")) } - gui.renderString("commitMessage", skipHookPreifx) + gui.renderStringSync("commitMessage", skipHookPreifx) if err := gui.getCommitMessageView().SetCursor(len(skipHookPreifx), 0); err != nil { return err } diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 35226b236..423cab90c 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -352,21 +352,25 @@ func (gui *Gui) setViewContent(v *gocui.View, s string) { // renderString resets the origin of a view and sets its content func (gui *Gui) renderString(viewName, s string) { gui.g.Update(func(*gocui.Gui) error { - v, err := gui.g.View(viewName) - if err != nil { - return nil // return gracefully if view has been deleted - } - if err := v.SetOrigin(0, 0); err != nil { - return err - } - if err := v.SetCursor(0, 0); err != nil { - return err - } - gui.setViewContent(v, s) - return nil + return gui.renderStringSync(viewName, s) }) } +func (gui *Gui) renderStringSync(viewName, s string) error { + v, err := gui.g.View(viewName) + if err != nil { + return nil // return gracefully if view has been deleted + } + if err := v.SetOrigin(0, 0); err != nil { + return err + } + if err := v.SetCursor(0, 0); err != nil { + return err + } + gui.setViewContent(v, s) + return nil +} + func (gui *Gui) optionsMapToString(optionsMap map[string]string) string { optionsArray := make([]string, 0) for key, description := range optionsMap { |