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'}) } } 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) 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) } } 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*\\("