diff --git a/crates/tinymist-std/src/battery.rs b/crates/tinymist-std/src/battery.rs index 93822aa8..31046f01 100644 --- a/crates/tinymist-std/src/battery.rs +++ b/crates/tinymist-std/src/battery.rs @@ -7,8 +7,12 @@ mod system { ::battery::Manager::new() .ok() .and_then(|manager| manager.batteries().ok()) - .map(|mut batteries| { - batteries.any(|battery| match battery { + .map(|batteries| { + let mut batteries = batteries.peekable(); + if batteries.peek().is_none() { + return false; + } + batteries.all(|battery| match battery { Ok(bat) => matches!(bat.state(), ::battery::State::Discharging), Err(_) => false, }) diff --git a/crates/typst-shim/src/syntax_only.rs b/crates/typst-shim/src/syntax_only.rs index 74491760..6620e149 100644 --- a/crates/typst-shim/src/syntax_only.rs +++ b/crates/typst-shim/src/syntax_only.rs @@ -11,7 +11,7 @@ pub static SYNTAX_ONLY: AtomicBool = AtomicBool::new(false); /// Check if syntax-only mode is enabled. pub fn is_syntax_only() -> bool { - SYNTAX_ONLY.load(Ordering::Relaxed) + SYNTAX_ONLY.load(Ordering::Acquire) } /// Compile the document if syntax-only mode is disabled; otherwise, return an diff --git a/docs/tinymist/feature/syntax-only-mode.typ b/docs/tinymist/feature/syntax-only-mode.typ index 45e90c10..52999d62 100644 --- a/docs/tinymist/feature/syntax-only-mode.typ +++ b/docs/tinymist/feature/syntax-only-mode.typ @@ -7,18 +7,18 @@ The syntax-only mode is available since `tinymist` v0.14.2. When working under power-saving mode or with resource-consumed projects, typst compilations costs too much CPU and memory resources. From a simple test on a typst document with 200 pages, containing complex figures and WASM plugin calls, editing a large `.typ` file on a windows laptop (i9-12900H), the CPU and memory usage are as follows: #align(center, table( - columns: 3, - [Mode], [CPU Usage], [Memory Usage], - [Normal Mode], [5% \~ 12%], [0.9\~1.184 GB], - [Syntax-Only Mode], [0% \~ 0.6%], [15.1\~16.0 MB], + columns: 4, + [Mode], [CPU Usage], [Memory Usage (Code Compilation)], [Memory Usage (Incremental Compilation)], + [Normal Mode], [5% \~ 12%], [2.72 GB], [6.62\~8.73GB], + [Syntax-Only Mode], [0% \~ 0.6%], [15.0 MB], [15.1\~16.0 MB], )) You can configure the extension to run in syntax only mode, i.e. only performing elementary tasks, like syntax checking, syntax-only code analysis and formatting by setting the `tinymist.syntaxOnly` to `enable` or `onPowerSaving` in the configuration. -The syntax-only mode is known to disable or disallowed: +The syntax-only mode is known to disable or limit the functionality of the following features: - typst preview feature. -- label completion. - compilation diagnostics. +- label completion. The syntax-only mode will be able to work with following features: - export PDF or other formats.