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
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -611,7 +611,6 @@ dependencies = [
|
|||
"serde_json",
|
||||
"settings",
|
||||
"smol",
|
||||
"terminal_view",
|
||||
"text",
|
||||
"toml 0.8.20",
|
||||
"ui",
|
||||
|
@ -5016,6 +5015,7 @@ dependencies = [
|
|||
"shellexpand 2.1.2",
|
||||
"smol",
|
||||
"telemetry",
|
||||
"terminal_view",
|
||||
"toml 0.8.20",
|
||||
"unindent",
|
||||
"util",
|
||||
|
@ -15616,6 +15616,7 @@ name = "terminal_view"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assistant_slash_command",
|
||||
"async-recursion 1.1.1",
|
||||
"breadcrumbs",
|
||||
"client",
|
||||
|
|
|
@ -217,7 +217,6 @@ fn register_slash_commands(cx: &mut App) {
|
|||
slash_command_registry.register_command(assistant_slash_commands::PromptSlashCommand, true);
|
||||
slash_command_registry.register_command(assistant_slash_commands::SelectionCommand, true);
|
||||
slash_command_registry.register_command(assistant_slash_commands::DefaultSlashCommand, false);
|
||||
slash_command_registry.register_command(assistant_slash_commands::TerminalSlashCommand, true);
|
||||
slash_command_registry.register_command(assistant_slash_commands::NowSlashCommand, false);
|
||||
slash_command_registry
|
||||
.register_command(assistant_slash_commands::DiagnosticsSlashCommand, true);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,7 +35,6 @@ rope.workspace = true
|
|||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
smol.workspace = true
|
||||
terminal_view.workspace = true
|
||||
text.workspace = true
|
||||
toml.workspace = true
|
||||
ui.workspace = true
|
||||
|
|
|
@ -12,11 +12,6 @@ mod selection_command;
|
|||
mod streaming_example_command;
|
||||
mod symbols_command;
|
||||
mod tab_command;
|
||||
mod terminal_command;
|
||||
|
||||
use gpui::App;
|
||||
use language::{CodeLabel, HighlightId};
|
||||
use ui::ActiveTheme as _;
|
||||
|
||||
pub use crate::cargo_workspace_command::*;
|
||||
pub use crate::context_server_command::*;
|
||||
|
@ -32,16 +27,5 @@ pub use crate::selection_command::*;
|
|||
pub use crate::streaming_example_command::*;
|
||||
pub use crate::symbols_command::*;
|
||||
pub use crate::tab_command::*;
|
||||
pub use crate::terminal_command::*;
|
||||
|
||||
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
|
||||
}
|
||||
use assistant_slash_command::create_label_for_command;
|
||||
|
|
|
@ -61,6 +61,7 @@ settings.workspace = true
|
|||
shellexpand.workspace = true
|
||||
smol.workspace = true
|
||||
telemetry.workspace = true
|
||||
terminal_view.workspace = true
|
||||
toml.workspace = true
|
||||
unindent.workspace = true
|
||||
util.workspace = true
|
||||
|
|
|
@ -424,6 +424,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
|
|||
language_models::init(user_store.clone(), client.clone(), fs.clone(), cx);
|
||||
languages::init(languages.clone(), node_runtime.clone(), cx);
|
||||
prompt_store::init(cx);
|
||||
terminal_view::init(cx);
|
||||
let stdout_is_a_pty = false;
|
||||
let prompt_builder = PromptBuilder::load(fs.clone(), stdout_is_a_pty, cx);
|
||||
agent::init(
|
||||
|
|
|
@ -18,6 +18,7 @@ doctest = false
|
|||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
async-recursion.workspace = true
|
||||
assistant_slash_command.workspace = true
|
||||
breadcrumbs.workspace = true
|
||||
collections.workspace = true
|
||||
db.workspace = true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use crate::{TerminalView, terminal_panel::TerminalPanel};
|
||||
use anyhow::Result;
|
||||
use assistant_slash_command::{
|
||||
ArgumentCompletion, SlashCommand, SlashCommandOutput, SlashCommandOutputSection,
|
||||
|
@ -8,11 +9,10 @@ use assistant_slash_command::{
|
|||
};
|
||||
use gpui::{App, Entity, Task, WeakEntity};
|
||||
use language::{BufferSnapshot, CodeLabel, LspAdapterDelegate};
|
||||
use terminal_view::{TerminalView, terminal_panel::TerminalPanel};
|
||||
use ui::prelude::*;
|
||||
use workspace::{Workspace, dock::Panel};
|
||||
|
||||
use super::create_label_for_command;
|
||||
use assistant_slash_command::create_label_for_command;
|
||||
|
||||
pub struct TerminalSlashCommand;
|
||||
|
|
@ -2,8 +2,10 @@ mod persistence;
|
|||
pub mod terminal_element;
|
||||
pub mod terminal_panel;
|
||||
pub mod terminal_scrollbar;
|
||||
mod terminal_slash_command;
|
||||
pub mod terminal_tab_tooltip;
|
||||
|
||||
use assistant_slash_command::SlashCommandRegistry;
|
||||
use editor::{Editor, EditorSettings, actions::SelectAll, scroll::ScrollbarAutoHide};
|
||||
use gpui::{
|
||||
AnyElement, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, KeyContext,
|
||||
|
@ -29,6 +31,7 @@ use terminal::{
|
|||
use terminal_element::{TerminalElement, is_blank};
|
||||
use terminal_panel::TerminalPanel;
|
||||
use terminal_scrollbar::TerminalScrollHandle;
|
||||
use terminal_slash_command::TerminalSlashCommand;
|
||||
use terminal_tab_tooltip::TerminalTooltip;
|
||||
use ui::{
|
||||
ContextMenu, Icon, IconName, Label, Scrollbar, ScrollbarState, Tooltip, h_flex, prelude::*,
|
||||
|
@ -78,6 +81,7 @@ actions!(terminal, [RerunTask]);
|
|||
impl_actions!(terminal, [SendText, SendKeystroke]);
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
assistant_slash_command::init(cx);
|
||||
terminal_panel::init(cx);
|
||||
terminal::init(cx);
|
||||
|
||||
|
@ -87,6 +91,7 @@ pub fn init(cx: &mut App) {
|
|||
workspace.register_action(TerminalView::deploy);
|
||||
})
|
||||
.detach();
|
||||
SlashCommandRegistry::global(cx).register_command(TerminalSlashCommand, true);
|
||||
}
|
||||
|
||||
pub struct BlockProperties {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue