zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.14k stars 1.17k forks source link

Autocomplete suggestions are displayed in each pane sharing the same file #1826

Open dmaluka opened 4 years ago

dmaluka commented 4 years ago

Description of the problem or steps to reproduce

When the same file is opened in 2 or more split panes, the autocomplete suggestions for it are displayed in the statusline of each of those panes, not only the active one.

Specifications

Commit hash: c6d0422 OS: any Terminal: any

dmaluka commented 4 years ago

Such a quick fix:

--- a/internal/display/statusline.go
+++ b/internal/display/statusline.go
@@ -100,7 +100,7 @@ func (s *StatusLine) Display() {

        b := s.win.Buf
        // autocomplete suggestions (for the buffer, not for the infowindow)
-       if b.HasSuggestions && len(b.Suggestions) > 1 {
+       if s.win.IsActive() && b.HasSuggestions && len(b.Suggestions) > 1 {
                statusLineStyle := config.DefStyle.Reverse(true)
                if style, ok := config.Colorscheme["statusline"]; ok {
                        statusLineStyle = style

is not enough: after focusing another pane via mouse click, the suggestions are now displayed for this newly focused pane (whereas we don't want them to be displayed for any pane), since b.HasSuggestions is still true.