Debounce spell check and add per-document incremental autocomplete #1

Open
Cyprien63 wants to merge 3 commits from Cyprien63/syspell:main into main
First-time contributor

Spell-checking:

  • Debounced 400ms after typing stops, with protection against stale results (per-block sequence token).
  • Global re-render (ResizeObserver) debounced to 300ms, without re-running spell-check.
  • storeBlocks no longer executes on every keystroke; runs only upon document opening or switching.
  • Block element cache invalidated once per transaction (single DOM traversal per event).

Autocomplete:

  • Per-document N-gram model, saved as JSON (data/storage) and reloaded on opening.
  • Incremental update for the block being typed in; no full regeneration.
  • Optimized search using a first-letter index and a pre-calculated list of frequent words.

Goal: Eliminate system freezes while typing.

Spell-checking: - Debounced 400ms after typing stops, with protection against stale results (per-block sequence token). - Global re-render (ResizeObserver) debounced to 300ms, without re-running spell-check. - `storeBlocks` no longer executes on every keystroke; runs only upon document opening or switching. - Block element cache invalidated once per transaction (single DOM traversal per event). Autocomplete: - Per-document N-gram model, saved as JSON (data/storage) and reloaded on opening. - Incremental update for the block being typed in; no full regeneration. - Optimized search using a first-letter index and a pre-calculated list of frequent words. Goal: Eliminate system freezes while typing.
Cyprien63 changed title from Debounce spell check and add per-document incremental autocomplete to WIP: Debounce spell check and add per-document incremental autocomplete 2026-09-09 12:16:35 +00:00
Cyprien63 changed title from WIP: Debounce spell check and add per-document incremental autocomplete to Debounce spell check and add per-document incremental autocomplete 2026-09-09 12:16:38 +00:00
- Add ModelStorage class to save/load ngram models via SiYuan file API
- Models stored in data/storage/petal/syspell/models/{docID}.json
- Eliminates freeze on doc open by restoring pre-built models
- Models persist across restarts
Owner

Thank you for your contribution.

I will check and test your commit as soon as I can.

Some preliminary thoughts: the performance enhancement is obviously a good thing, but I'm a bit skeptical about the word prediction stuff.
I'm not sure if that belongs in SySpell. Since SySpell's stated goal is bringing an experience like LanguageTool and Grammarly to SiYuan, this feature might be out of scope. I will have to test it myself, see if I find it to be useful and aligned with the project's objective.

For now, thank you again. I will surely let you know more once I test it.

Thank you for your contribution. I will check and test your commit as soon as I can. Some preliminary thoughts: the performance enhancement is obviously a good thing, but I'm a bit skeptical about the word prediction stuff. I'm not sure if that belongs in SySpell. Since SySpell's stated goal is bringing an experience like LanguageTool and Grammarly to SiYuan, this feature might be out of scope. I will have to test it myself, see if I find it to be useful and aligned with the project's objective. For now, thank you again. I will surely let you know more once I test it.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u main:Cyprien63-main
git switch Cyprien63-main

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff Cyprien63-main
git switch Cyprien63-main
git rebase main
git switch main
git merge --ff-only Cyprien63-main
git switch Cyprien63-main
git rebase main
git switch main
git merge --no-ff Cyprien63-main
git switch main
git merge --squash Cyprien63-main
git switch main
git merge --ff-only Cyprien63-main
git switch main
git merge Cyprien63-main
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
massivebox/syspell!1
No description provided.