Add slash command completion - #8
Merged
Revantark merged 6 commits intoAug 30, 2026
Merged
Conversation
- register a `/` backend so commands complete like `@` paths, each listed with its description; candidates come from `SlashCommand` itself - items carry `Accept`, so Enter runs a command outright while a path accepted inside a command line stays a path - popup height tracks its contents instead of always reserving five rows - popup keys are decided by one pure `PopupAction::of` rather than split across the event dispatch
Pairs with the existing selected() index, and frees up highlight for the text styling it already means elsewhere in the view.
Names what it stands in for rather than its return type, and the doc now says what None means.
The key decision only ever read selected_item, so taking it directly makes of a pure function of the key and that item, and its tests stop needing a controller.
A command is the whole input, so a `/` opening a continuation line is prose. Offering one there let the popup take keys the editor needed: Up and Down moved the selection instead of moving between lines, Tab inserted a command name instead of indenting, and Enter rewrote the line before submitting, so `hello\n/he` went out as `hello\n/help `. `CompletionRequest` now carries the row, which is what lets `Commands` decline anywhere but the start of the buffer.
`ranked_items` narrowed the candidates to `&[String]` even though `rank_all` was already generic, so the backend had to store names and parse them back to reach a description. Widening it lets `Commands` hold `SlashCommand` directly and drops the round trip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slash commands had highlighting and dispatch but no popup, so
/was the only trigger the completion architecture did not serve. This registers it as a backend alongside@paths.Commandsbackend keyed to/, listing each command with its description. Candidates come fromSlashCommanditself, so the popup cannot offer one that does not exist./in the first column starts a command, soexplain /usr/binstill completes as a path.CompletionItemcarriesAccept, set by the backend that offered it. Enter runs a command outright; a path accepted inside a command line stays a path and does not fire it.PopupAction::of, replacing a decision that was split between the event dispatch and the key handler. Makes the key table testable without an editor, which is how the Shift+Tab and empty-popup paths got covered.