()
| 374 | } |
| 375 | |
| 376 | private setupAutocomplete(): void { |
| 377 | const slashCommands: SlashAutocompleteCommand[] = this.getSlashCommands().map((cmd) => { |
| 378 | const completer = cmd.completeArgs; |
| 379 | return { |
| 380 | name: cmd.name, |
| 381 | aliases: cmd.aliases, |
| 382 | description: cmd.description, |
| 383 | ...(cmd.argumentHint !== undefined ? { argumentHint: cmd.argumentHint } : {}), |
| 384 | ...(completer !== undefined |
| 385 | ? { getArgumentCompletions: (prefix: string) => completer(prefix) } |
| 386 | : {}), |
| 387 | }; |
| 388 | }); |
| 389 | const provider = new FileMentionProvider( |
| 390 | slashCommands, |
| 391 | this.state.appState.workDir, |
| 392 | this.fdPath, |
| 393 | this.state.appState.additionalDirs, |
| 394 | () => this.state.appState.inputMode, |
| 395 | ); |
| 396 | this.state.editor.setAutocompleteProvider(provider); |
| 397 | |
| 398 | const argumentHints = new Map<string, string>(); |
| 399 | for (const cmd of slashCommands) { |
| 400 | if (cmd.argumentHint === undefined) continue; |
| 401 | argumentHints.set(cmd.name, cmd.argumentHint); |
| 402 | for (const alias of cmd.aliases ?? []) { |
| 403 | argumentHints.set(alias, cmd.argumentHint); |
| 404 | } |
| 405 | } |
| 406 | this.state.editor.setArgumentHints(argumentHints); |
| 407 | } |
| 408 | |
| 409 | refreshSlashCommandAutocomplete(): void { |
| 410 | this.setupAutocomplete(); |
no test coverage detected