mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 00:07:46 +02:00
feat: immediately accept
This commit is contained in:
@ -325,6 +325,7 @@ bench = false
|
||||
# changing versions in each sub-crate of the workspace is tedious
|
||||
[patch.crates-io]
|
||||
# reedline = { git = "https://github.com/nushell/reedline", branch = "main" }
|
||||
reedline = { git = "https://github.com/mrdgo/reedline.git", rev = "3a6ad518", features = ["bashisms", "sqlite"] }
|
||||
# nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"}
|
||||
|
||||
# Run all benchmarks with `cargo bench`
|
||||
|
@ -26,6 +26,11 @@ impl Command for SubCommand {
|
||||
"replaces the current contents of the buffer (default)",
|
||||
Some('r'),
|
||||
)
|
||||
.switch(
|
||||
"accept",
|
||||
"immediately executes the result after edit",
|
||||
Some('A'),
|
||||
)
|
||||
.required(
|
||||
"str",
|
||||
SyntaxShape::String,
|
||||
@ -61,6 +66,13 @@ impl Command for SubCommand {
|
||||
repl.buffer = str;
|
||||
repl.cursor_pos = repl.buffer.len();
|
||||
}
|
||||
|
||||
if call.has_flag(engine_state, stack, "accept")? {
|
||||
if let Ok(mut flag) = engine_state.immediately_execute.lock() {
|
||||
*flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::nothing(call.head).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
@ -481,7 +481,18 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
line_editor = line_editor.with_transient_prompt(transient_prompt);
|
||||
let input = line_editor.read_line(nu_prompt);
|
||||
|
||||
let input = line_editor.read_line(
|
||||
nu_prompt,
|
||||
if let Ok(mut flag) = engine_state.immediately_execute.lock() {
|
||||
let ret = *flag;
|
||||
*flag = false;
|
||||
ret
|
||||
} else {
|
||||
false
|
||||
},
|
||||
);
|
||||
|
||||
// we got our inputs, we can now drop our stack references
|
||||
// This lists all of the stack references that we have cleaned up
|
||||
line_editor = line_editor
|
||||
|
@ -95,6 +95,7 @@ pub struct EngineState {
|
||||
pub config: Arc<Config>,
|
||||
pub pipeline_externals_state: Arc<(AtomicU32, AtomicU32)>,
|
||||
pub repl_state: Arc<Mutex<ReplState>>,
|
||||
pub immediately_execute: Arc<Mutex<bool>>,
|
||||
pub table_decl_id: Option<DeclId>,
|
||||
#[cfg(feature = "plugin")]
|
||||
pub plugin_path: Option<PathBuf>,
|
||||
@ -180,6 +181,7 @@ impl EngineState {
|
||||
startup_time: -1,
|
||||
is_debugging: IsDebugging::new(false),
|
||||
debugger: Arc::new(Mutex::new(Box::new(NoopDebugger))),
|
||||
immediately_execute: Arc::new(Mutex::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user