]> git.lizzy.rs Git - micro.git/commitdiff
Fix suggestions display (#1825)
authorDmitry Maluka <dmitrymaluka@gmail.com>
Sun, 18 Oct 2020 00:48:39 +0000 (02:48 +0200)
committerGitHub <noreply@github.com>
Sun, 18 Oct 2020 00:48:39 +0000 (20:48 -0400)
Fix the following bugs:

- If a split pane is not at the left edge of the screen, the statusline
with suggestions for it is displayed at wrong place.

- When keymenu is enabled, the statusline with suggestions is not
displayed at all.

internal/display/statusline.go

index 5c5f551280d1e4b972979b4c1eb3c255a666cbd9..b94acdef37fadf5d75a44111e96da5685cc70454 100644 (file)
@@ -98,6 +98,8 @@ func (s *StatusLine) Display() {
        // We'll draw the line at the lowest line in the window
        y := s.win.Height + s.win.Y - 1
 
+       winX := s.win.X
+
        b := s.win.Buf
        // autocomplete suggestions (for the buffer, not for the infowindow)
        if b.HasSuggestions && len(b.Suggestions) > 1 {
@@ -105,10 +107,6 @@ func (s *StatusLine) Display() {
                if style, ok := config.Colorscheme["statusline"]; ok {
                        statusLineStyle = style
                }
-               keymenuOffset := 0
-               if config.GetGlobalOption("keymenu").(bool) {
-                       keymenuOffset = len(keydisplay)
-               }
                x := 0
                for j, sug := range b.Suggestions {
                        style := statusLineStyle
@@ -116,13 +114,13 @@ func (s *StatusLine) Display() {
                                style = style.Reverse(true)
                        }
                        for _, r := range sug {
-                               screen.SetContent(x, y-keymenuOffset, r, nil, style)
+                               screen.SetContent(winX+x, y, r, nil, style)
                                x++
                                if x >= s.win.Width {
                                        return
                                }
                        }
-                       screen.SetContent(x, y-keymenuOffset, ' ', nil, statusLineStyle)
+                       screen.SetContent(winX+x, y, ' ', nil, statusLineStyle)
                        x++
                        if x >= s.win.Width {
                                return
@@ -130,7 +128,7 @@ func (s *StatusLine) Display() {
                }
 
                for x < s.win.Width {
-                       screen.SetContent(x, y-keymenuOffset, ' ', nil, statusLineStyle)
+                       screen.SetContent(winX+x, y, ' ', nil, statusLineStyle)
                        x++
                }
                return
@@ -170,7 +168,6 @@ func (s *StatusLine) Display() {
        leftLen := util.StringWidth(leftText, util.CharacterCount(leftText), 1)
        rightLen := util.StringWidth(rightText, util.CharacterCount(rightText), 1)
 
-       winX := s.win.X
        for x := 0; x < s.win.Width; x++ {
                if x < leftLen {
                        r, combc, size := util.DecodeCharacter(leftText)