diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2020-11-13 12:00:22 +0100 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2020-11-13 12:01:09 +0100 |
commit | 23131981b029bb6e332975c22caaa467affab216 (patch) | |
tree | 3117183469cbaee9ba30f526ca29e7f3a541567b /app.go | |
parent | Don't autocomplete on empty word (diff) |
/topic completion
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 34 |
1 files changed, 4 insertions, 30 deletions
@@ -455,36 +455,10 @@ func (app *App) completions(cursorIdx int, text []rune) []ui.Completion { return cs } - var start int - for start = cursorIdx - 1; 0 <= start; start-- { - if text[start] == ' ' { - break - } - } - start++ - word := text[start:cursorIdx] - 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) { - nickComp := []rune(name.Name.Name) - if start == 0 { - nickComp = append(nickComp, ':') - } - nickComp = append(nickComp, ' ') - c := make([]rune, len(text)+len(nickComp)-len(word)) - copy(c[:start], text[:start]) - if cursorIdx < len(text) { - copy(c[start+len(nickComp):], text[cursorIdx:]) - } - copy(c[start:], nickComp) - cs = append(cs, ui.Completion{ - Text: c, - CursorIdx: start + len(nickComp), - }) - } + buffer := app.win.CurrentBuffer() + if app.s.IsChannel(buffer) { + cs = app.completionsChannelTopic(cs, cursorIdx, text) + cs = app.completionsChannelMembers(cs, cursorIdx, text) } if cs != nil { |