diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index 48140b4427..80ae28b103 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -5,11 +5,10 @@ use nu_color_config::{color_record_to_nustyle, lookup_ansi_color_style}; use nu_engine::eval_block; use nu_parser::parse; use nu_protocol::{ - create_menus, debugger::WithoutDebug, engine::{EngineState, Stack, StateWorkingSet}, - extract_value, Config, EditBindings, ParsedKeybinding, ParsedMenu, PipelineData, Record, - ShellError, Span, Value, + extract_value, Config, EditBindings, FromValue, ParsedKeybinding, ParsedMenu, PipelineData, + Record, ShellError, Span, Type, Value, }; use reedline::{ default_emacs_keybindings, default_vi_insert_keybindings, default_vi_normal_keybindings, @@ -173,15 +172,13 @@ pub(crate) fn add_menus( for res in menu_eval_results.into_iter() { if let PipelineData::Value(value, None) = res { - for menu in create_menus(&value)? { - line_editor = add_menu( - line_editor, - &menu, - new_engine_state_ref.clone(), - stack, - config.clone(), - )?; - } + line_editor = add_menu( + line_editor, + &ParsedMenu::from_value(value)?, + new_engine_state_ref.clone(), + stack, + config.clone(), + )?; } } @@ -204,22 +201,22 @@ fn add_menu( "list" => add_list_menu(line_editor, menu, engine_state, stack, config), "ide" => add_ide_menu(line_editor, menu, engine_state, stack, config), "description" => add_description_menu(line_editor, menu, engine_state, stack, config), - _ => Err(ShellError::UnsupportedConfigValue { - expected: "columnar, list, ide or description".to_string(), - value: menu.r#type.to_abbreviated_string(&config), - span: menu.r#type.span(), + str => Err(ShellError::InvalidValue { + valid: "'columnar', 'list', 'ide', or 'description'".into(), + actual: format!("'{str}'"), + span, }), } } else { - Err(ShellError::UnsupportedConfigValue { - expected: "only record type".to_string(), - value: menu.r#type.to_abbreviated_string(&config), - span: menu.r#type.span(), + Err(ShellError::RuntimeTypeMismatch { + expected: Type::record(), + actual: menu.r#type.get_type(), + span, }) } } -fn get_style(record: &Record, name: &str, span: Span) -> Option