Skip to content

Add slash command completion - #8

Merged
Revantark merged 6 commits into
Revantark:mainfrom
azeemshaik025:feat/slash-command-completion
Aug 30, 2026
Merged

Add slash command completion#8
Revantark merged 6 commits into
Revantark:mainfrom
azeemshaik025:feat/slash-command-completion

Conversation

@azeemshaik025

Copy link
Copy Markdown
Collaborator

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.

  • Commands backend keyed to /, listing each command with its description. Candidates come from SlashCommand itself, so the popup cannot offer one that does not exist.
  • Only a / in the first column starts a command, so explain /usr/bin still completes as a path.
  • CompletionItem carries Accept, 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.
  • Popup height now tracks its contents rather than always reserving five rows, so three commands no longer leave two blank rows above the prompt.
  • Popup key handling moved into one pure 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.

- 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.
@Revantark
Revantark merged commit 1ba6fdd into Revantark:main Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants