summaryrefslogtreecommitdiff
path: root/completions.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-10-20 17:33:10 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-10-24 12:57:24 +0200
commit9fb4378753ddec61a504a0dec403f40d6def7e90 (patch)
tree32955930be2d97614f3ec6290f67d0556769a16e /completions.go
parentRemove draft file (diff)
Support for soju.im/bouncer-networks
This patch also disable the highlight on reconnect. This might be an issue (the user would want to know when senpai is online again?), but with multiple connections, it's bothersome to have to unread all of them on start (it wasn't a problem with only one connection since it was read instantly). Now, lastbuffer.txt also contains the network ID, otherwise the user might end up on another buffer with the same name. This patch does not extend /r to support multiple networks (it will send the message to the latest query, whatever the current displayed network is).
Diffstat (limited to 'completions.go')
-rw-r--r--completions.go19
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 "))