ADR-0022 stage 3/8: simple-mode echo lines highlighted
Lift `dsl::ECHO_PREFIX = "running: "` as a public const,
with a unit test asserting `t!("dsl.running", input = "")`
matches it. The catalog template is now contracted to equal
`format!("{ECHO_PREFIX}{input}")` — a translator changing
the prefix breaks the test.
Add `input_render::lex_to_runs(input, theme)` — a
cursor-less variant of `render_input_runs` for use cases
(echo lines, future hint panel) that need token-class
colouring without an inverted cursor.
ui::render_output_line: when the line is an Echo submitted
in Simple mode, peel the prefix and re-tokenise the rest
through lex_to_runs, rendering each token at its class
colour. Advanced-mode echoes and any echo whose body
unexpectedly lacks the prefix fall through to the plain
rendering.
Tests: 683 passing, 0 failing, 1 ignored (682 baseline →
+1 echo_prefix_matches_catalog_template). Clippy clean
(uses let-chain to keep the if condition flat).
Stage 4 adds render-time parse + error overlay so the
failing token in mid-typed input lights up in the error
colour.
This commit is contained in:
@@ -26,3 +26,31 @@ pub use command::{
|
||||
pub use parser::{ParseError, parse_command};
|
||||
pub use types::Type;
|
||||
pub use value::Value;
|
||||
|
||||
/// Prefix every echoed DSL command carries in the output
|
||||
/// panel — i.e. `[simple] running: <input>` reads as
|
||||
/// `[simple]` (tag) + `running: ` (this constant) + the
|
||||
/// user's input.
|
||||
///
|
||||
/// The catalog template `dsl.running` is contracted to equal
|
||||
/// `format!("{ECHO_PREFIX}{{input}}")`. The constant lives
|
||||
/// in code because the echo-line renderer (ADR-0022 §5)
|
||||
/// peels this prefix off and re-tokenises the rest for
|
||||
/// highlighting; a unit test (`echo_prefix_matches_catalog_template`)
|
||||
/// pins the binding.
|
||||
pub const ECHO_PREFIX: &str = "running: ";
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ECHO_PREFIX;
|
||||
|
||||
#[test]
|
||||
fn echo_prefix_matches_catalog_template() {
|
||||
// The catalog template `dsl.running` must produce
|
||||
// `<ECHO_PREFIX><input>` so the echo-line renderer can
|
||||
// peel the prefix and re-tokenise the rest. A
|
||||
// translator changing the prefix breaks this test.
|
||||
let rendered = crate::t!("dsl.running", input = "");
|
||||
assert_eq!(rendered, ECHO_PREFIX);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user