diff --git a/crates/highlight/src/lib.rs b/crates/highlight/src/lib.rs index aa8c7b0cc5..0928e1a04c 100644 --- a/crates/highlight/src/lib.rs +++ b/crates/highlight/src/lib.rs @@ -22,10 +22,10 @@ pub fn highlight(code: &str) -> Vec { // Special-case that even though it's normally not a valid highlight. const REPL_PROMPT: &str = "ยป"; - let code = if code.starts_with(REPL_PROMPT) { + let code = if let Some(stripped) = code.strip_prefix(REPL_PROMPT) { buf = push_html_span(buf, REPL_PROMPT, "kw"); - &code[REPL_PROMPT.len()..] + stripped } else { code };