mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
Plugin API 1.12 adds workspace set-console-rules: a plugin replaces its list of highlight rules (regex in the Rust/JS common subset, validated on the host and bounded to 512 bytes and 100 rules; palette foreground/background, styles, whole-line or match-only, enabled). Every window applies the rules to the stdout and stderr lines of its Run and Debug consoles; the plugin never sees the output, and the rules go away when the plugin stops. Components rebuilt for 1.12. Closes #3304 Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
18 lines
930 B
Rust
18 lines
930 B
Rust
use openidea_plugin::{ConsoleRule, Error, host, mock::MockHost};
|
|
|
|
#[test]
|
|
fn rules_replace_the_previous_list_without_a_capability() {
|
|
let mock = MockHost::install().with_capabilities(&[]);
|
|
let audit = ConsoleRule::new(r"\[AUDIT\]").foreground("bright-yellow").style("bold").whole_line();
|
|
let job = ConsoleRule::new(r"job-\d+").ignore_case().background("blue").enabled(false);
|
|
host::set_console_rules(&[audit.clone(), job.clone()]).unwrap();
|
|
assert_eq!(mock.console_rules(), [audit.clone(), job]);
|
|
assert!(audit.whole_line && audit.enabled && !audit.ignore_case);
|
|
|
|
assert!(matches!(host::set_console_rules(&[ConsoleRule::new("")]), Err(Error::Invalid(_))));
|
|
assert!(matches!(host::set_console_rules(&vec![ConsoleRule::new("x"); 101]), Err(Error::Invalid(_))));
|
|
assert_eq!(mock.console_rules().len(), 2);
|
|
host::set_console_rules(&[]).unwrap();
|
|
assert!(mock.console_rules().is_empty());
|
|
}
|