Introduce a new /tabs command (#12382)

This inserts the content of the open tabs sorted by recency.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-05-28 17:17:34 +02:00 committed by GitHub
parent b466a8b828
commit 371abd37f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 174 additions and 77 deletions

View file

@ -1,5 +1,5 @@
use crate::prompts::{generate_content_prompt, PromptLibrary, PromptManager};
use crate::slash_command::search_command;
use crate::slash_command::{search_command, tabs_command};
use crate::{
assistant_settings::{AssistantDockPosition, AssistantSettings, ZedDotDevModel},
codegen::{self, Codegen, CodegenKind},
@ -210,6 +210,7 @@ impl AssistantPanel {
prompt_command::PromptSlashCommand::new(prompt_library.clone()),
);
slash_command_registry.register_command(active_command::ActiveSlashCommand);
slash_command_registry.register_command(tabs_command::TabsSlashCommand);
slash_command_registry.register_command(project_command::ProjectSlashCommand);
slash_command_registry.register_command(search_command::SearchSlashCommand);
@ -1883,15 +1884,15 @@ impl Conversation {
async move {
let output = output.await;
this.update(&mut cx, |this, cx| match output {
Ok(output) => {
Ok(mut output) => {
if !output.text.ends_with('\n') {
output.text.push('\n');
}
let sections = this.buffer.update(cx, |buffer, cx| {
let start = command_range.start.to_offset(buffer);
let old_end = command_range.end.to_offset(buffer);
let new_end = start + output.text.len();
buffer.edit([(start..old_end, output.text)], None, cx);
if buffer.chars_at(new_end).next() != Some('\n') {
buffer.edit([(new_end..new_end, "\n")], None, cx);
}
let mut sections = output
.sections