From 23131981b029bb6e332975c22caaa467affab216 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Fri, 13 Nov 2020 12:00:22 +0100 Subject: /topic completion --- app.go | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'app.go') diff --git a/app.go b/app.go index a10c665..569fe8a 100644 --- a/app.go +++ b/app.go @@ -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 { -- cgit v1.2.3