From 6e638ab381273bd2845106ec8cdebb630478c902 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Sat, 10 Jun 2023 22:42:13 +0800 Subject: [PATCH] disable bracketed paste during evaluation (#9399) # Description Fixes: #9218 When user execute some commands involve user input, currently if we enable `bracketed_paste`, it will results strange behavior (Pasting `0~` and `1~` around texts, e.g: `aaa` -> `0~aaa1~`) And this is why `gpg` with paste failed. Sorry that it's hard to make relative testing... # User-Facing Changes # Tests + Formatting # After Submitting --- Cargo.lock | 3 +-- Cargo.toml | 2 +- crates/nu-cli/src/repl.rs | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3963531a7b..1ceac5093e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4320,8 +4320,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d18dd49ff50c5be37fc21e1cd0ab42f5533e339906ce0527748b396b5a5a55dc" +source = "git+https://github.com/nushell/reedline.git?branch=main#de2c627951d0a0e198146e1faa112b74bf92e9c3" dependencies = [ "chrono", "crossterm 0.26.1", diff --git a/Cargo.toml b/Cargo.toml index 8370eac476..7a06a7bf0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ bench = false # To use a development version of a dependency please use a global override here # changing versions in each sub-crate of the workspace is tedious [patch.crates-io] -# reedline = { git = "https://github.com/nushell/reedline.git", branch = "main"} +reedline = { git = "https://github.com/nushell/reedline.git", branch = "main"} # nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"} # Criterion benchmarking setup diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 4c2933ff67..5d1a48af22 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -607,6 +607,11 @@ pub fn evaluate_repl( } } + // should disable bracketed_paste to avoid strange pasting behavior + // while running commands. + #[cfg(not(target_os = "windows"))] + let _ = line_editor.disable_bracketed_paste(); + eval_source( engine_state, stack, @@ -615,6 +620,10 @@ pub fn evaluate_repl( PipelineData::empty(), false, ); + if engine_state.get_config().bracketed_paste { + #[cfg(not(target_os = "windows"))] + let _ = line_editor.enable_bracketed_paste(); + } } let cmd_duration = start_time.elapsed();