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
This commit is contained in:
Chris Denton 2025-01-15 12:21:58 +00:00 committed by GitHub
parent 4e1b06cb51
commit 46566296c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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