commit f5c03fa
Hubert Hirtz
·
2020-10-12 09:45:59 +0000 UTC
parent 3ea19ff
Fix crash when completing nicks with special chars Not enough space was allocated for the completed text when the word being completed had characters encoded in more than one byte. This was because "word" was a string instead of a []rune, thus "len(word)" counted each byte instead of each character. Fixes #42
2 files changed,
+2,
-3
M
app.go
M
app.go
+2,
-2
1@@ -377,8 +377,8 @@ func (app *App) completions(cursorIdx int, text []rune) []ui.Completion {
2 }
3 }
4 start++
5- word := string(text[start:cursorIdx])
6- wordCf := app.s.Casemap(word)
7+ word := text[start:cursorIdx]
8+ wordCf := app.s.Casemap(string(word))
9 for _, name := range app.s.Names(app.win.CurrentBuffer()) {
10 if strings.HasPrefix(app.s.Casemap(name.Name.Name), wordCf) {
11 nickComp := []rune(name.Name.Name)
+0,
-1
1@@ -35,7 +35,6 @@ type Editor struct {
2 autoComplete func(cursorIdx int, text []rune) []Completion
3 autoCache []Completion
4 autoCacheIdx int
5- completeIdx int
6 }
7
8 func NewEditor(width int, autoComplete func(cursorIdx int, text []rune) []Completion) Editor {