fix: syntax highlighting was broken in bundled app

This commit is contained in:
2026-07-21 21:05:24 +02:00
parent 8170076e9b
commit 8e78a5fc2b
4 changed files with 41 additions and 28 deletions

30
Cargo.lock generated
View File

@@ -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",
]

View File

@@ -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"

View File

@@ -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");
}
}

View File

@@ -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::<HashSet<_>>();
assert!(colors.len() > 1, "linked editor should use syntax colors");
}