Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for stacks to have parents #11654

Merged
merged 2 commits into from Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion crates/nu-cli/src/nu_highlight.rs
@@ -1,7 +1,7 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type, Value};
use reedline::Highlighter;
use reedline::{Highlighter, StyledText};

#[derive(Clone)]
pub struct NuHighlight;
Expand Down Expand Up @@ -64,3 +64,16 @@ impl Command for NuHighlight {
}]
}
}

/// A highlighter that does nothing
///
/// Used to remove highlighting from a reedline instance
/// (letting NuHighlighter structs be dropped)
#[derive(Default)]
pub struct NoOpHighlighter {}

impl Highlighter for NoOpHighlighter {
fn highlight(&self, _line: &str, _cursor: usize) -> reedline::StyledText {
StyledText::new()
}
}
18 changes: 7 additions & 11 deletions crates/nu-cli/src/prompt_update.rs
Expand Up @@ -99,12 +99,10 @@ fn get_prompt_string(
pub(crate) fn update_prompt(
config: &Config,
engine_state: &EngineState,
stack: &Stack,
stack: &mut Stack,
nu_prompt: &mut NushellPrompt,
) {
let mut stack = stack.clone();
IanManske marked this conversation as resolved.
Show resolved Hide resolved

let left_prompt_string = get_prompt_string(PROMPT_COMMAND, config, engine_state, &mut stack);
let left_prompt_string = get_prompt_string(PROMPT_COMMAND, config, engine_state, stack);

// Now that we have the prompt string lets ansify it.
// <133 A><prompt><133 B><command><133 C><command output>
Expand All @@ -120,20 +118,18 @@ pub(crate) fn update_prompt(
left_prompt_string
};

let right_prompt_string =
get_prompt_string(PROMPT_COMMAND_RIGHT, config, engine_state, &mut stack);
let right_prompt_string = get_prompt_string(PROMPT_COMMAND_RIGHT, config, engine_state, stack);

let prompt_indicator_string =
get_prompt_string(PROMPT_INDICATOR, config, engine_state, &mut stack);
let prompt_indicator_string = get_prompt_string(PROMPT_INDICATOR, config, engine_state, stack);

let prompt_multiline_string =
get_prompt_string(PROMPT_MULTILINE_INDICATOR, config, engine_state, &mut stack);
get_prompt_string(PROMPT_MULTILINE_INDICATOR, config, engine_state, stack);

let prompt_vi_insert_string =
get_prompt_string(PROMPT_INDICATOR_VI_INSERT, config, engine_state, &mut stack);
get_prompt_string(PROMPT_INDICATOR_VI_INSERT, config, engine_state, stack);

let prompt_vi_normal_string =
get_prompt_string(PROMPT_INDICATOR_VI_NORMAL, config, engine_state, &mut stack);
get_prompt_string(PROMPT_INDICATOR_VI_NORMAL, config, engine_state, stack);

// apply the other indicators
nu_prompt.update_all_prompt_strings(
Expand Down