chore: Make terminal_view own the TerminalSlashCommand
This reduces 'touch crates/editor/src/editor.rs && cargo +nightly build' from 8.9s to 8.5s. That same scenario used to take 8s less than a week ago. :)
This commit is contained in:
parent
77c2aecf93
commit
a3513fb2b2
10 changed files with 27 additions and 22 deletions
|
@ -9,6 +9,7 @@ use anyhow::Result;
|
|||
use futures::StreamExt;
|
||||
use futures::stream::{self, BoxStream};
|
||||
use gpui::{App, SharedString, Task, WeakEntity, Window};
|
||||
use language::HighlightId;
|
||||
use language::{BufferSnapshot, CodeLabel, LspAdapterDelegate, OffsetRangeExt};
|
||||
pub use language_model::Role;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -16,6 +17,7 @@ use std::{
|
|||
ops::Range,
|
||||
sync::{Arc, atomic::AtomicBool},
|
||||
};
|
||||
use ui::ActiveTheme;
|
||||
use workspace::{Workspace, ui::IconName};
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
|
@ -325,6 +327,18 @@ impl SlashCommandLine {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_label_for_command(command_name: &str, arguments: &[&str], cx: &App) -> CodeLabel {
|
||||
let mut label = CodeLabel::default();
|
||||
label.push_str(command_name, None);
|
||||
label.push_str(" ", None);
|
||||
label.push_str(
|
||||
&arguments.join(" "),
|
||||
cx.theme().syntax().highlight_id("comment").map(HighlightId),
|
||||
);
|
||||
label.filter_range = 0..command_name.len();
|
||||
label
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue