1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

move cursor to right when using auto prefix

This commit is contained in:
Jesse Duffield 2020-08-16 18:25:08 +10:00
parent 28cd827cea
commit c8add47fe7
2 changed files with 17 additions and 13 deletions

View File

@ -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
}

View File

@ -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 {