fix: update code and docs about syntax mode (#2248)

which was detected by gemini review.
This commit is contained in:
Myriad-Dreamin 2025-11-16 09:15:04 +08:00 committed by GitHub
parent 9d5beb196b
commit f5db6e8d31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 9 deletions

View file

@ -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,
})

View file

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

View file

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