assistant: Implement /selection slash command (#19988)

- Closes #18868

## Summary
This PR introduces a new slash command `/selection` to enhance the
usability of the assistant's quote selection feature.

## Changes Made
1. Extracted a function from the `assistant: quote selection` action to
find the selected text and format it as an assistant section.
2. Created a new slash command `/selection` that utilizes the extracted
function to achieve the same effect as the existing `assistant: quote
selection` action.
3. Updated the documentation to include information about the new
`/selection` slash command.


Release Notes:

- Moved the text selection action to a slash command (`/selection`) in
the assistant panel

---------

Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
This commit is contained in:
Tristan Marechaux 2024-11-05 18:42:10 +01:00 committed by GitHub
parent db11a3b554
commit 2364804f17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 206 additions and 89 deletions

View file

@ -13,6 +13,7 @@ Slash commands enhance the assistant's capabilities. Begin by typing a `/` at th
- `/symbols`: Inserts the current tab's active symbols into the context
- `/tab`: Inserts the content of the active tab or all open tabs into the context
- `/terminal`: Inserts a select number of lines of output from the terminal
- `/selection`: Inserts the selected text into the context
### Other Commands:
@ -95,6 +96,14 @@ Usage: `/terminal [<number>]`
- `<number>`: Optional parameter to specify the number of lines to insert (default is a 50).
## `/selection`
The `/selection` command inserts the selected text in the editor into the context. This is useful for referencing specific parts of your code.
This is equivalent to the `assistant: quote selection` command ({#kb assistant::QuoteSelection}). See [Interacting with the Assistant](./assistant-panel.md#interacting-with-the-assistant)).
Usage: `/selection`
## `/workflow`
The `/workflow` command inserts a prompt that opts into the edit workflow. This sets up the context for the assistant to suggest edits to your code.