From b2620eb68c62a6672bb9854c7d057af8aa6cb379 Mon Sep 17 00:00:00 2001 From: XeroOl Date: Fri, 16 Oct 2020 00:44:48 -0500 Subject: [PATCH 1/4] update lua.yaml (#1892) added `break` as a keyword --- runtime/syntax/lua.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/syntax/lua.yaml b/runtime/syntax/lua.yaml index e5dab4ef..934f6a31 100644 --- a/runtime/syntax/lua.yaml +++ b/runtime/syntax/lua.yaml @@ -4,7 +4,7 @@ detect: filename: "\\.lua$" rules: - - statement: "\\b(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\\b" + - statement: "\\b(do|end|while|break|repeat|until|if|elseif|then|else|for|in|function|local|return)\\b" - statement: "\\b(not|and|or)\\b" - statement: "\\b(debug|string|math|table|io|coroutine|os|utf8|bit32)\\b\\." - statement: "\\b(_ENV|_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\s*\\(" From 92e9060bcd41cd177fe58ba60328201b004c0925 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Sun, 18 Oct 2020 02:48:39 +0200 Subject: [PATCH 2/4] Fix suggestions display (#1825) 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 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/display/statusline.go b/internal/display/statusline.go index 5c5f5512..b94acdef 100644 --- a/internal/display/statusline.go +++ b/internal/display/statusline.go @@ -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) From 23162f7a344c661936d6ca804ac38650b3688be6 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Sun, 18 Oct 2020 02:53:08 +0200 Subject: [PATCH 3/4] Add tabbar.active color group (#1831) Added tabbar.active color group for displaying the name of the active tab in the tabbar with different colors. If tabbar.active is not defined in the colorscheme, the active tab name is displayed with the same colors as inactive ones. Ref #1646 --- internal/display/tabwindow.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/internal/display/tabwindow.go b/internal/display/tabwindow.go index 6263586d..70694504 100644 --- a/internal/display/tabwindow.go +++ b/internal/display/tabwindow.go @@ -98,8 +98,16 @@ func (w *TabWindow) Display() { if style, ok := config.Colorscheme["tabbar"]; ok { tabBarStyle = style } + tabBarActiveStyle := tabBarStyle + if style, ok := config.Colorscheme["tabbar.active"]; ok { + tabBarActiveStyle = style + } - draw := func(r rune, n int) { + draw := func(r rune, n int, active bool) { + style := tabBarStyle + if active { + style = tabBarActiveStyle + } for i := 0; i < n; i++ { rw := runewidth.RuneWidth(r) for j := 0; j < rw; j++ { @@ -114,7 +122,7 @@ func (w *TabWindow) Display() { } else if x == 0 && w.hscroll > 0 { screen.SetContent(0, w.Y, '<', nil, tabBarStyle) } else if x >= 0 && x < w.Width { - screen.SetContent(x, w.Y, c, nil, tabBarStyle) + screen.SetContent(x, w.Y, c, nil, style) } x++ } @@ -123,21 +131,21 @@ func (w *TabWindow) Display() { for i, n := range w.Names { if i == w.active { - draw('[', 1) + draw('[', 1, true) } else { - draw(' ', 1) + draw(' ', 1, false) } for _, c := range n { - draw(c, 1) + draw(c, 1, i == w.active) } if i == len(w.Names)-1 { done = true } if i == w.active { - draw(']', 1) - draw(' ', 2) + draw(']', 1, true) + draw(' ', 2, true) } else { - draw(' ', 3) + draw(' ', 3, false) } if x >= w.Width { break @@ -145,6 +153,6 @@ func (w *TabWindow) Display() { } if x < w.Width { - draw(' ', w.Width-x) + draw(' ', w.Width-x, false) } } From 298fa40f9021a28bdfbef108fa4365480038fe99 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Tue, 20 Oct 2020 02:36:14 +0200 Subject: [PATCH 4/4] Fix buffer.RuneAt (#1895) Fix buffer.RuneAt returning the rune not at the given location (as the documentation claims) but just before it. --- internal/buffer/autocomplete.go | 4 ++-- internal/buffer/buffer.go | 3 ++- internal/buffer/save.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/buffer/autocomplete.go b/internal/buffer/autocomplete.go index b1c061cd..414e3060 100644 --- a/internal/buffer/autocomplete.go +++ b/internal/buffer/autocomplete.go @@ -69,11 +69,11 @@ func GetWord(b *Buffer) ([]byte, int) { l := b.LineBytes(c.Y) l = util.SliceStart(l, c.X) - if c.X == 0 || util.IsWhitespace(b.RuneAt(c.Loc)) { + if c.X == 0 || util.IsWhitespace(b.RuneAt(c.Loc.Move(-1, b))) { return []byte{}, -1 } - if util.IsNonAlphaNumeric(b.RuneAt(c.Loc)) { + if util.IsNonAlphaNumeric(b.RuneAt(c.Loc.Move(-1, b))) { return []byte{}, c.X } diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index 43be4a81..387b041c 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -511,11 +511,12 @@ func (b *Buffer) RuneAt(loc Loc) rune { for len(line) > 0 { r, _, size := util.DecodeCharacter(line) line = line[size:] - i++ if i == loc.X { return r } + + i++ } } return '\n' diff --git a/internal/buffer/save.go b/internal/buffer/save.go index d037fb92..e912055d 100644 --- a/internal/buffer/save.go +++ b/internal/buffer/save.go @@ -109,7 +109,7 @@ func (b *Buffer) saveToFile(filename string, withSudo bool) error { if b.Settings["eofnewline"].(bool) { end := b.End() - if b.RuneAt(Loc{end.X, end.Y}) != '\n' { + if b.RuneAt(Loc{end.X - 1, end.Y}) != '\n' { b.insert(end, []byte{'\n'}) } }