forked from extern/nushell
fix: set repl_buffer_state
to the REPL buffer after the `pre_execut… (#8560)
…ion` hook # Description Previously when a `executehostcommand` shortcut calls `commandline`, to get the current command line, it's incorrectly set to the value of `executehostcommand` `cmd`. This fixes the regression (due to #8207), so it's correctly set to what's in the REPL buffer. # User-Facing Changes # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
parent
cb1eefd24a
commit
b9858ea8f8
@ -460,32 +460,29 @@ pub fn evaluate_repl(
|
|||||||
.into_diagnostic()?; // todo: don't stop repl if error here?
|
.into_diagnostic()?; // todo: don't stop repl if error here?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right before we start running the code the user gave us,
|
// Right before we start running the code the user gave us, fire the `pre_execution`
|
||||||
// fire the "pre_execution" hook
|
// hook
|
||||||
if let Some(hook) = config.hooks.pre_execution.clone() {
|
if let Some(hook) = config.hooks.pre_execution.clone() {
|
||||||
// Set the REPL buffer to the current command for the "pre_execution" hook
|
// Set the REPL buffer to the current command for the "pre_execution" hook
|
||||||
let mut repl_buffer = engine_state
|
let mut repl_buffer = engine_state
|
||||||
.repl_buffer_state
|
.repl_buffer_state
|
||||||
.lock()
|
.lock()
|
||||||
.expect("repl buffer state mutex");
|
.expect("repl buffer state mutex");
|
||||||
let next_repl_buffer = repl_buffer.to_string();
|
|
||||||
*repl_buffer = s.to_string();
|
*repl_buffer = s.to_string();
|
||||||
drop(repl_buffer);
|
drop(repl_buffer);
|
||||||
|
|
||||||
if let Err(err) = eval_hook(engine_state, stack, None, vec![], &hook) {
|
if let Err(err) = eval_hook(engine_state, stack, None, vec![], &hook) {
|
||||||
report_error_new(engine_state, &err);
|
report_error_new(engine_state, &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the REPL buffer state for the next command. It could've been edited
|
|
||||||
// by `commandline`.
|
|
||||||
let mut repl_buffer = engine_state
|
|
||||||
.repl_buffer_state
|
|
||||||
.lock()
|
|
||||||
.expect("repl buffer state mutex");
|
|
||||||
*repl_buffer = next_repl_buffer;
|
|
||||||
drop(repl_buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut repl_buffer = engine_state
|
||||||
|
.repl_buffer_state
|
||||||
|
.lock()
|
||||||
|
.expect("repl buffer state mutex");
|
||||||
|
*repl_buffer = line_editor.current_buffer_contents().to_string();
|
||||||
|
drop(repl_buffer);
|
||||||
|
|
||||||
if shell_integration {
|
if shell_integration {
|
||||||
run_ansi_sequence(PRE_EXECUTE_MARKER)?;
|
run_ansi_sequence(PRE_EXECUTE_MARKER)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user