diff options
Diffstat (limited to 'completions.go')
-rw-r--r-- | completions.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/completions.go b/completions.go index db8a7f7..3e4a516 100644 --- a/completions.go +++ b/completions.go @@ -18,9 +18,11 @@ func (app *App) completionsChannelMembers(cs []ui.Completion, cursorIdx int, tex if len(word) == 0 { return cs } - wordCf := app.s.Casemap(string(word)) - for _, name := range app.s.Names(app.win.CurrentBuffer()) { - if strings.HasPrefix(app.s.Casemap(name.Name.Name), wordCf) { + netID, buffer := app.win.CurrentBuffer() + s := app.sessions[netID] // is not nil + wordCf := s.Casemap(string(word)) + for _, name := range s.Names(buffer) { + if strings.HasPrefix(s.Casemap(name.Name.Name), wordCf) { nickComp := []rune(name.Name.Name) if start == 0 { nickComp = append(nickComp, ':') @@ -45,7 +47,9 @@ func (app *App) completionsChannelTopic(cs []ui.Completion, cursorIdx int, text if !hasPrefix(text, []rune("/topic ")) { return cs } - topic, _, _ := app.s.Topic(app.win.CurrentBuffer()) + netID, buffer := app.win.CurrentBuffer() + s := app.sessions[netID] // is not nil + topic, _, _ := s.Topic(buffer) if cursorIdx == len(text) { compText := append(text, []rune(topic)...) cs = append(cs, ui.Completion{ @@ -60,6 +64,7 @@ func (app *App) completionsMsg(cs []ui.Completion, cursorIdx int, text []rune) [ if !hasPrefix(text, []rune("/msg ")) { return cs } + s := app.CurrentSession() // is not nil // Check if the first word (target) is already written and complete (in // which case we don't have completions to provide). var word string @@ -69,15 +74,15 @@ func (app *App) completionsMsg(cs []ui.Completion, cursorIdx int, text []rune) [ return cs } if !hasMetALetter && text[i] != ' ' { - word = app.s.Casemap(string(text[i:cursorIdx])) + word = s.Casemap(string(text[i:cursorIdx])) hasMetALetter = true } } if word == "" { return cs } - for _, user := range app.s.Users() { - if strings.HasPrefix(app.s.Casemap(user), word) { + for _, user := range s.Users() { + if strings.HasPrefix(s.Casemap(user), word) { nickComp := append([]rune(user), ' ') c := make([]rune, len(text)+5+len(nickComp)-cursorIdx) copy(c[:5], []rune("/msg ")) |