support bracketed paste (#8907)

# Description

Relative: #8113, #7630
It works on non-windows system

This pr depends on https://github.com/nushell/reedline/pull/571
This commit is contained in:
WindSoilder 2023-05-04 05:08:47 +08:00 committed by GitHub
parent 7fb48b9a2f
commit e4625acf24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 3 deletions

3
Cargo.lock generated
View File

@ -4326,8 +4326,7 @@ dependencies = [
[[package]]
name = "reedline"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8684e0f5d6fb8529156a19c637645dd7fd5018efbdeaa306f53f54e3b404de"
source = "git+https://github.com/nushell/reedline.git?branch=main#65c4e7a419122a526b66adb9695d9d924bf921f6"
dependencies = [
"chrono",
"crossterm 0.26.1",

View File

@ -160,7 +160,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

View File

@ -105,6 +105,12 @@ pub fn evaluate_repl(
);
let config = engine_state.get_config();
if config.bracketed_paste {
// try to enable bracketed paste
// It doesn't work on windows system: https://github.com/crossterm-rs/crossterm/issues/737
#[cfg(not(target_os = "windows"))]
let _ = line_editor.enable_bracketed_paste();
}
// Setup history_isolation aka "history per session"
let history_isolation = config.history_isolation;

View File

@ -100,6 +100,7 @@ pub struct Config {
pub enable_external_completion: bool,
pub trim_strategy: TrimStrategy,
pub show_banner: bool,
pub bracketed_paste: bool,
pub show_clickable_links_in_ls: bool,
pub render_right_prompt_on_last_line: bool,
pub explore: HashMap<String, Value>,
@ -144,6 +145,7 @@ impl Default for Config {
enable_external_completion: true,
trim_strategy: TRIM_STRATEGY_DEFAULT,
show_banner: true,
bracketed_paste: true,
show_clickable_links_in_ls: true,
render_right_prompt_on_last_line: false,
explore: HashMap::new(),
@ -1212,6 +1214,9 @@ impl Value {
"render_right_prompt_on_last_line" => {
try_bool!(cols, vals, index, span, render_right_prompt_on_last_line);
}
"bracketed_paste" => {
try_bool!(cols, vals, index, span, bracketed_paste);
}
// Legacy config options (deprecated as of 2022-11-02)
// Legacy options do NOT reconstruct their values on error
"use_ls_colors" => {

View File

@ -294,6 +294,7 @@ let-env config = {
float_precision: 2 # the precision for displaying floats in tables
# buffer_editor: "emacs" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL
use_ansi_coloring: true
bracketed_paste: true # enable bracketed paste, currently useless on windows
edit_mode: emacs # emacs, vi
shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.