From 8e78a5fc2b6a7c5dd1847dd15bd7a324e5ce1b30 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Tue, 21 Jul 2026 21:05:24 +0200 Subject: [PATCH] fix: syntax highlighting was broken in bundled app --- Cargo.lock | 30 +++++++++------------ Cargo.toml | 4 +-- crates/bds-server/build.rs | 9 ------- crates/bds-ui/tests/bundled_highlighting.rs | 26 ++++++++++++++++++ 4 files changed, 41 insertions(+), 28 deletions(-) delete mode 100644 crates/bds-server/build.rs create mode 100644 crates/bds-ui/tests/bundled_highlighting.rs diff --git a/Cargo.lock b/Cargo.lock index 2535e69..adf0548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,19 +374,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi-to-tui" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42366bb9d958f042bf58f0a85e1b2d091997c1257ca49bddd7e4827aadc65fd" -dependencies = [ - "nom 8.0.0", - "ratatui-core", - "simdutf8", - "smallvec", - "thiserror 2.0.19", -] - [[package]] name = "anstream" version = "1.0.0" @@ -3059,6 +3046,17 @@ dependencies = [ "regex", ] +[[package]] +name = "fancy-regex" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" +dependencies = [ + "bit-set 0.8.0", + "regex-automata", + "regex-syntax", +] + [[package]] name = "fast-srgb8" version = "1.0.0" @@ -9513,10 +9511,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925" dependencies = [ "bincode", + "fancy-regex 0.16.2", "flate2", "fnv", "once_cell", - "onig", "plist", "regex-syntax", "serde", @@ -9646,7 +9644,7 @@ dependencies = [ "anyhow", "base64 0.22.1", "bitflags 2.13.1", - "fancy-regex", + "fancy-regex 0.11.0", "filedescriptor", "finl_unicode", "fixedbitset", @@ -10180,13 +10178,11 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6779056a6ae2d46013edb3692be1eb55d2e1d3f0d1d454042163efe1b64baca" dependencies = [ - "ansi-to-tui", "itertools 0.15.0", "pretty_assertions", "pulldown-cmark 0.13.4", "ratatui-core", "rstest", - "syntect", "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index e388107..d161ef2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ ort = { version = "=2.0.0-rc.12", default-features = false, features = ["std", " russh = "0.62.2" ratatui = "0.30.2" ratatui-image = { version = "11.0.6", default-features = false, features = ["crossterm", "image-defaults"] } -tui-markdown = "0.3.8" +tui-markdown = { version = "0.3.8", default-features = false } # UI framework iced = { version = "0.13", features = ["wgpu", "advanced", "canvas", "image", "svg", "tokio", "markdown"] } @@ -68,7 +68,7 @@ iced = { version = "0.13", features = ["wgpu", "advanced", "canvas", "image", "s # Editor widget cosmic-text = "0.12" ropey = "1" -syntect = "5" +syntect = { version = "5", default-features = false, features = ["default-fancy"] } # Platform integration (cross-platform) muda = "0.15" diff --git a/crates/bds-server/build.rs b/crates/bds-server/build.rs deleted file mode 100644 index 751709d..0000000 --- a/crates/bds-server/build.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - // syntect and fastembed both reach onig_sys across separate Rust dylibs. - // Keep the vendored static archive on this dylib's final native link line. - if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { - println!("cargo:rustc-link-arg=onig.lib"); - } else { - println!("cargo:rustc-link-arg=-lonig"); - } -} diff --git a/crates/bds-ui/tests/bundled_highlighting.rs b/crates/bds-ui/tests/bundled_highlighting.rs new file mode 100644 index 0000000..34e8194 --- /dev/null +++ b/crates/bds-ui/tests/bundled_highlighting.rs @@ -0,0 +1,26 @@ +use std::collections::HashSet; + +#[test] +fn linked_editor_highlights_markdown() { + // Retain the dylib that previously interposed bds-editor's regex symbols. + let _ = std::hint::black_box( + bds_server::run_headless + as fn(bds_server::boot::BootMode, bds_server::ServerConfig) -> anyhow::Result<()>, + ); + let highlighter = bds_editor::highlighter(); + assert_eq!( + highlighter.syntax_for_extension("md").name, + "Markdown with Macros" + ); + let colors = highlighter + .highlight_lines( + "plain\n# Heading\n[link](https://example.com)\n`code`", + highlighter.syntax_for_extension("md"), + ) + .into_iter() + .flatten() + .map(|(style, _)| style.foreground) + .collect::>(); + + assert!(colors.len() > 1, "linked editor should use syntax colors"); +}