diff --git a/.rules b/.rules index 136c4de46af26eaeec1aba8476721f36b20cebf2..a2ee71cb0f6f08b0a16c9336e46154e6f6ec74d3 100644 --- a/.rules +++ b/.rules @@ -136,4 +136,4 @@ Other entities can then register a callback to handle these events by doing `cx. ## Build guidelines - Use `./script/clippy` instead of `cargo clippy` -- Always use `-q` when invoking `cargo` +- Always invoke `cargo` commands with the `-q` flag diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 0d264f9e58363f5e8d8e23dff565d512f118a8d1..73aebb9c2308d72ac7f6e74f0c9eb07ccac7dcab 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -65,6 +65,7 @@ postage.workspace = true prettier.workspace = true rand.workspace = true regex.workspace = true +release_channel.workspace = true remote.workspace = true rpc.workspace = true schemars.workspace = true @@ -110,7 +111,6 @@ language = { workspace = true, features = ["test-support"] } lsp = { workspace = true, features = ["test-support"] } prettier = { workspace = true, features = ["test-support"] } pretty_assertions.workspace = true -release_channel.workspace = true rpc = { workspace = true, features = ["test-support"] } settings = { workspace = true, features = ["test-support"] } snippet_provider = { workspace = true, features = ["test-support"] } diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index 9e9c9fe423ca7cc619851f05dc66f14a9c626712..c19f7b46c499d1a0368102a0d491d354ce26a800 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -14,7 +14,8 @@ use std::{ }; use task::{Shell, ShellBuilder, ShellKind, SpawnInTerminal}; use terminal::{ - TaskState, TaskStatus, Terminal, TerminalBuilder, terminal_settings::TerminalSettings, + TaskState, TaskStatus, Terminal, TerminalBuilder, insert_zed_terminal_env, + terminal_settings::TerminalSettings, }; use util::{command::new_std_command, get_default_system_shell, maybe, rel_path::RelPath}; @@ -568,8 +569,7 @@ fn create_remote_shell( remote_client: Entity, cx: &mut App, ) -> Result<(Shell, HashMap)> { - // Set default terminfo that does not break the highlighting via ssh. - env.insert("TERM".to_string(), "xterm-256color".to_string()); + insert_zed_terminal_env(&mut env, &release_channel::AppVersion::global(cx)); let (program, args) = match spawn_command { Some((program, args)) => (Some(program.clone()), args), diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index e64780e2945363e71b357b79aee57024484d417c..ca556cf78ee831d76c36bae8b6cdeb0b29e9f3ae 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -113,6 +113,19 @@ const DEBUG_TERMINAL_HEIGHT: Pixels = px(30.); const DEBUG_CELL_WIDTH: Pixels = px(5.); const DEBUG_LINE_HEIGHT: Pixels = px(5.); +/// Inserts Zed-specific environment variables for terminal sessions. +/// Used by both local terminals and remote terminals (via SSH). +pub fn insert_zed_terminal_env( + env: &mut HashMap, + version: &impl std::fmt::Display, +) { + env.insert("ZED_TERM".to_string(), "true".to_string()); + env.insert("TERM_PROGRAM".to_string(), "zed".to_string()); + env.insert("TERM".to_string(), "xterm-256color".to_string()); + env.insert("COLORTERM".to_string(), "truecolor".to_string()); + env.insert("TERM_PROGRAM_VERSION".to_string(), version.to_string()); +} + ///Upward flowing events, for changing the title and such #[derive(Clone, Debug, PartialEq, Eq)] pub enum Event { @@ -435,11 +448,7 @@ impl TerminalBuilder { .or_insert_with(|| "en_US.UTF-8".to_string()); } - env.insert("ZED_TERM".to_string(), "true".to_string()); - env.insert("TERM_PROGRAM".to_string(), "zed".to_string()); - env.insert("TERM".to_string(), "xterm-256color".to_string()); - env.insert("COLORTERM".to_string(), "truecolor".to_string()); - env.insert("TERM_PROGRAM_VERSION".to_string(), version.to_string()); + insert_zed_terminal_env(&mut env, &version); #[derive(Default)] struct ShellParams {