Commit b0c7e4ff0e

b0c7e4ff0e47282dc2530939b51d8360d6a1b5a0

parent: d156ebda4a

Unsigned

Sandro Santilli (AI assisted) <strk@kbt.io> · 2026-08-05 07:02 UTC

fix: complete room nicks in thread buffers

WeeChat's built-in "nicks" completion reads the current buffer's
nicklist, which thread buffers keep empty, so Tab-completion of room
members did nothing there. Hook the "nick" completion item so thread
buffers contribute the parent room's members; room buffers are left to
the built-in nicklist completion.

Assisted-By: opencode/big-pickle via opencode 1.18.11

Layout: unified · split

src/completions.rs +53 −1
@@ -19,6 +19,7 @@ pub struct Completions {
1919 servers: CompletionHook,
2020 users: CompletionHook,
2121 media: CompletionHook,
22 nicks: CompletionHook,
2223}
2324
2425impl Completions {
@@ -29,7 +30,8 @@ impl Completions {
2930 )?,
3031 servers: ServersCompletion::create(servers.clone())?,
3132 users: UsersCompletion::create(servers.clone())?,
32 media: MediaCompletion::create(servers)?,
33 media: MediaCompletion::create(servers.clone())?,
34 nicks: NicksCompletion::create(servers)?,
3335 })
3436 }
3537}
@@ -163,6 +165,56 @@ impl CompletionCallback for UsersCompletion {
163165 }
164166}
165167
168/// Feed room member nicks into WeeChat's built-in "nicks" completion.
169///
170/// Thread buffers keep an empty nicklist, so the built-in fallback of
171/// completing from the current buffer's nicklist finds no candidates
172/// there. Adding the parent room's members here makes nick completion
173/// work in thread buffers, while room buffers keep using the built-in
174/// nicklist completion (this hook adds nothing for them, so WeeChat
175/// falls back to it).
176struct NicksCompletion {
177 servers: Servers,
178}
179
180impl NicksCompletion {
181 fn create(servers: Servers) -> Result<CompletionHook, ()> {
182 let comp = NicksCompletion { servers };
183
184 CompletionHook::new(
185 "nick",
186 "Completion for Matrix room member nicks",
187 comp,
188 )
189 }
190}
191
192impl CompletionCallback for NicksCompletion {
193 fn callback(
194 &mut self,
195 _: &Weechat,
196 buffer: &Buffer,
197 _: Cow<str>,
198 completion: &Completion,
199 ) -> Result<(), ()> {
200 if buffer.get_localvar("thread_root").is_none() {
201 return Ok(());
202 }
203
204 if let Some(room) = self.servers.find_room(buffer) {
205 for nick in room.names() {
206 completion.add_with_options(
207 &nick,
208 true,
209 CompletionPosition::Sorted,
210 )
211 }
212 }
213
214 Ok(())
215 }
216}
217
166218struct MediaCompletion {
167219 servers: Servers,
168220}