Skip to content

Commit

Permalink
Don't cut off last line of text in panel above select widget
Browse files Browse the repository at this point in the history
There's an off-by-one (or possibly off-by-two) error in the
current implementation of the select widget, when there's
content in the panel above it.  This means the last line of
text in the panel is overwritten by the select widget (i.e.
the select widget is one line too high).  This commit changes
the logic slightly to offset the select widget by the number
of lines of panel content plus one, allowing all the text
in the panel to be shown.

Signed-off-by: Tim Serong <[email protected]>
(cherry picked from commit 19c750d)
  • Loading branch information
tserong authored and bk201 committed Jan 19, 2024
1 parent 602b50f commit 5b6255d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/widgets/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ func (s *Select) Show() error {
return err
}
optionViewName := s.Name + "-options"
offset := len(strings.Split(s.Content, "\n"))
y0 := s.Y0 + offset - 1
y1 := s.Y0 + offset + len(s.options)
offset := 0
if len(s.Content) > 0 {
offset = len(strings.Split(s.Content, "\n")) + 1
}
y0 := s.Y0 + offset
y1 := s.Y0 + offset + len(s.options) + 1
v, err := s.g.SetView(optionViewName, s.X0, y0, s.X1, y1)
if err != nil {
if err != gocui.ErrUnknownView {
Expand Down

0 comments on commit 5b6255d

Please sign in to comment.