From 2fd42d25b1c9f2b39e17af8a2164bafc18c724c1 Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Thu, 3 Mar 2022 09:13:44 +0000 Subject: [PATCH] partial completions (#4704) --- Cargo.lock | 2 +- crates/nu-protocol/src/config.rs | 9 +++++++++ docs/sample_config/default_config.nu | 1 + src/repl.rs | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0362bcdbcd..a25eb2546d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.2.0" -source = "git+https://github.com/nushell/reedline?branch=main#3d933d52cee44b889b2d92b9688e071a8e4b992d" +source = "git+https://github.com/nushell/reedline?branch=main#e9c1e37d7cd0d301362b2b900a85dcaf3de05d53" dependencies = [ "chrono", "crossterm", diff --git a/crates/nu-protocol/src/config.rs b/crates/nu-protocol/src/config.rs index 98fb1c6e61..140e74618d 100644 --- a/crates/nu-protocol/src/config.rs +++ b/crates/nu-protocol/src/config.rs @@ -26,6 +26,7 @@ pub struct Config { pub filesize_format: String, pub use_ansi_coloring: bool, pub quick_completions: bool, + pub partial_completions: bool, pub edit_mode: String, pub max_history_size: i64, pub log_level: String, @@ -49,6 +50,7 @@ impl Default for Config { filesize_format: "auto".into(), use_ansi_coloring: true, quick_completions: true, + partial_completions: true, edit_mode: "emacs".into(), max_history_size: 1000, log_level: String::new(), @@ -160,6 +162,13 @@ impl Value { eprintln!("$config.quick_completions is not a bool") } } + "partial_completions" => { + if let Ok(b) = value.as_bool() { + config.partial_completions = b; + } else { + eprintln!("$config.partial_completions is not a bool") + } + } "rm_always_trash" => { if let Ok(b) = value.as_bool() { config.rm_always_trash = b; diff --git a/docs/sample_config/default_config.nu b/docs/sample_config/default_config.nu index 7435105c98..b2c6f0db16 100644 --- a/docs/sample_config/default_config.nu +++ b/docs/sample_config/default_config.nu @@ -170,6 +170,7 @@ let $config = { use_grid_icons: true footer_mode: "25" # always, never, number_of_rows, auto quick_completions: true # set this to false to prevent auto-selecting completions when only one remains + partial_completions: true # set this to false to prevent partial filling of the prompt animate_prompt: false # redraw the prompt every second float_precision: 2 use_ansi_coloring: true diff --git a/src/repl.rs b/src/repl.rs index 909a411fc4..0d16edab67 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -147,6 +147,7 @@ pub(crate) fn evaluate( stack.vars.get(&CONFIG_VARIABLE_ID).cloned(), ))) .with_quick_completions(config.quick_completions) + .with_partial_completions(config.partial_completions) .with_ansi_colors(config.use_ansi_coloring); if is_perf_true() {