From 46566296c02b98370729d4221370e71077f14650 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 15 Jan 2025 12:21:58 +0000 Subject: [PATCH] Use non-canonicalized paths in shell integrations (#14832) This simply replaces uses of the deprecated function `current_dir_str` with `EngineState::cwd_as_string` in `run_shell_integration_*` functions. The main difference being that the latter does not canonicalize paths. Fixes #14619 --- crates/nu-cli/src/repl.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 5d27dea59f..b8fef7355d 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -19,7 +19,7 @@ use miette::{ErrReport, IntoDiagnostic, Result}; use nu_cmd_base::util::get_editor; use nu_color_config::StyleComputer; #[allow(deprecated)] -use nu_engine::{current_dir_str, env_to_strings}; +use nu_engine::env_to_strings; use nu_parser::{lex, parse, trim_quotes_str}; use nu_protocol::{ config::NuCursorShape, @@ -971,8 +971,7 @@ fn run_shell_integration_osc2( stack: &mut Stack, use_color: bool, ) { - #[allow(deprecated)] - if let Ok(path) = current_dir_str(engine_state, stack) { + if let Ok(path) = engine_state.cwd_as_string(Some(stack)) { let start_time = Instant::now(); // Try to abbreviate string for windows title @@ -1016,8 +1015,7 @@ fn run_shell_integration_osc7( stack: &mut Stack, use_color: bool, ) { - #[allow(deprecated)] - if let Ok(path) = current_dir_str(engine_state, stack) { + if let Ok(path) = engine_state.cwd_as_string(Some(stack)) { let start_time = Instant::now(); // Otherwise, communicate the path as OSC 7 (often used for spawning new tabs in the same dir) @@ -1040,8 +1038,7 @@ fn run_shell_integration_osc7( } fn run_shell_integration_osc9_9(engine_state: &EngineState, stack: &mut Stack, use_color: bool) { - #[allow(deprecated)] - if let Ok(path) = current_dir_str(engine_state, stack) { + if let Ok(path) = engine_state.cwd_as_string(Some(stack)) { let start_time = Instant::now(); // Otherwise, communicate the path as OSC 9;9 from ConEmu (often used for spawning new tabs in the same dir) @@ -1065,8 +1062,7 @@ fn run_shell_integration_osc633( use_color: bool, repl_cmd_line_text: String, ) { - #[allow(deprecated)] - if let Ok(path) = current_dir_str(engine_state, stack) { + if let Ok(path) = engine_state.cwd_as_string(Some(stack)) { // Supported escape sequences of Microsoft's Visual Studio Code (vscode) // https://code.visualstudio.com/docs/terminal/shell-integration#_supported-escape-sequences if stack