Ensure context inserted via commands is syntax-highlighted (#13133)

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2024-06-17 11:57:56 +02:00 committed by GitHub
parent bedf57db89
commit 2b46a4a0e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 61 additions and 47 deletions

View file

@ -1,11 +1,14 @@
use super::{file_command::FilePlaceholder, SlashCommand, SlashCommandOutput};
use super::{
file_command::{codeblock_fence_for_path, FilePlaceholder},
SlashCommand, SlashCommandOutput,
};
use anyhow::{anyhow, Result};
use assistant_slash_command::SlashCommandOutputSection;
use collections::HashMap;
use editor::Editor;
use gpui::{AppContext, Entity, Task, WeakView};
use language::LspAdapterDelegate;
use std::{fmt::Write, path::Path, sync::Arc};
use std::{fmt::Write, sync::Arc};
use ui::{IntoElement, WindowContext};
use workspace::Workspace;
@ -77,15 +80,7 @@ impl SlashCommand for TabsSlashCommand {
let mut text = String::new();
for (full_path, buffer, _) in open_buffers {
let section_start_ix = text.len();
writeln!(
text,
"```{}\n",
full_path
.as_deref()
.unwrap_or(Path::new("untitled"))
.display()
)
.unwrap();
text.push_str(&codeblock_fence_for_path(full_path.as_deref(), None));
for chunk in buffer.as_rope().chunks() {
text.push_str(chunk);
}