Skip to content

Commit

Permalink
fix: fix initial scroll position of edit box
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryooooooga committed Aug 18, 2022
1 parent ef82f39 commit 3ada4dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/gui/confirmation_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (gui *Gui) prepareConfirmationPanel(
gui.Views.Confirmation.Wrap = !opts.Editable
gui.Views.Confirmation.FgColor = theme.GocuiDefaultTextColor
gui.Views.Confirmation.Mask = runeForMask(opts.Mask)
_ = gui.Views.Confirmation.SetOrigin(0, 0)

gui.findSuggestions = opts.FindSuggestionsFunc
if opts.FindSuggestionsFunc != nil {
Expand All @@ -133,6 +134,7 @@ func (gui *Gui) prepareConfirmationPanel(
suggestionsView.Title = fmt.Sprintf(gui.c.Tr.SuggestionsTitle, gui.c.UserConfig.Keybinding.Universal.TogglePanel)
}

gui.resizeConfirmationPanel()
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/view_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func (gui *Gui) resizeConfirmationPanel() {
}
panelWidth := gui.getConfirmationPanelWidth()
prompt := gui.Views.Confirmation.Buffer()
panelHeight := gui.getMessageHeight(true, prompt, panelWidth) + suggestionsViewHeight
wrap := !gui.Views.Confirmation.Editable
panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth) + suggestionsViewHeight
x0, y0, x1, y1 := gui.getConfirmationPanelDimensionsAux(panelWidth, panelHeight)
confirmationViewBottom := y1 - suggestionsViewHeight
_, _ = gui.g.SetView(gui.Views.Confirmation.Name(), x0, y0, x1, confirmationViewBottom, 0)
Expand Down

0 comments on commit 3ada4dd

Please sign in to comment.