mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:25:42 +02:00
Reuse Closure
type in Value::Closure
(#10894)
# Description Reuses the existing `Closure` type in `Value::Closure`. This will help with the span refactoring for `Value`. Additionally, this allows us to more easily box or unbox the `Closure` case should we chose to do so in the future. # User-Facing Changes Breaking API change for `nu_protocol`.
This commit is contained in:
@ -40,13 +40,9 @@ fn get_prompt_string(
|
||||
stack
|
||||
.get_env_var(engine_state, prompt)
|
||||
.and_then(|v| match v {
|
||||
Value::Closure {
|
||||
val: block_id,
|
||||
captures,
|
||||
..
|
||||
} => {
|
||||
let block = engine_state.get_block(block_id);
|
||||
let mut stack = stack.captures_to_stack(&captures);
|
||||
Value::Closure { val, .. } => {
|
||||
let block = engine_state.get_block(val.block_id);
|
||||
let mut stack = stack.captures_to_stack(&val.captures);
|
||||
// Use eval_subexpression to force a redirection of output, so we can use everything in prompt
|
||||
let ret_val =
|
||||
eval_subexpression(engine_state, &mut stack, block, PipelineData::empty());
|
||||
|
@ -248,11 +248,11 @@ pub(crate) fn add_columnar_menu(
|
||||
Value::Nothing { .. } => {
|
||||
Ok(line_editor.with_menu(ReedlineMenu::EngineCompleter(Box::new(columnar_menu))))
|
||||
}
|
||||
Value::Closure { val, captures, .. } => {
|
||||
Value::Closure { val, .. } => {
|
||||
let menu_completer = NuMenuCompleter::new(
|
||||
*val,
|
||||
val.block_id,
|
||||
span,
|
||||
stack.captures_to_stack(captures),
|
||||
stack.captures_to_stack(&val.captures),
|
||||
engine_state,
|
||||
only_buffer_difference,
|
||||
);
|
||||
@ -330,11 +330,11 @@ pub(crate) fn add_list_menu(
|
||||
Value::Nothing { .. } => {
|
||||
Ok(line_editor.with_menu(ReedlineMenu::HistoryMenu(Box::new(list_menu))))
|
||||
}
|
||||
Value::Closure { val, captures, .. } => {
|
||||
Value::Closure { val, .. } => {
|
||||
let menu_completer = NuMenuCompleter::new(
|
||||
*val,
|
||||
val.block_id,
|
||||
span,
|
||||
stack.captures_to_stack(captures),
|
||||
stack.captures_to_stack(&val.captures),
|
||||
engine_state,
|
||||
only_buffer_difference,
|
||||
);
|
||||
@ -448,11 +448,11 @@ pub(crate) fn add_description_menu(
|
||||
completer,
|
||||
}))
|
||||
}
|
||||
Value::Closure { val, captures, .. } => {
|
||||
Value::Closure { val, .. } => {
|
||||
let menu_completer = NuMenuCompleter::new(
|
||||
*val,
|
||||
val.block_id,
|
||||
span,
|
||||
stack.captures_to_stack(captures),
|
||||
stack.captures_to_stack(&val.captures),
|
||||
engine_state,
|
||||
only_buffer_difference,
|
||||
);
|
||||
|
Reference in New Issue
Block a user