Skip to content

fix(init): recover deferred syntax when tick changes during ft retry#199

Merged
barrettruth merged 2 commits intomainfrom
fix/deferred-syntax-stale
Mar 20, 2026
Merged

fix(init): recover deferred syntax when tick changes during ft retry#199
barrettruth merged 2 commits intomainfrom
fix/deferred-syntax-stale

Conversation

@barrettruth
Copy link
Owner

Problem

When did_filetype() blocks filetype detection (.sh, .bash, etc.), ensure_cache schedules a retry via vim.schedule that calls invalidate_cache (setting tick=-1) then redraw!. The deferred syntax callback from on_win then sees a stale tick and aborts, leaving hunks without treesitter syntax highlighting permanently.

Solution

Instead of aborting when the tick changes, fall back to the current cache's hunks that have a resolved lang field. This allows the deferred syntax pass to apply treesitter highlighting even after the ft retry invalidation cycle.

barrettruth and others added 2 commits March 19, 2026 21:57
Problem: when `did_filetype()` blocks filetype detection (e.g. `.sh`,
`.bash`), `ensure_cache` schedules a retry via `vim.schedule` that
calls `invalidate_cache` (setting `tick=-1`) then `redraw!`. The
deferred syntax callback from `on_win` then sees a stale tick and
aborts, leaving hunks without treesitter syntax highlighting.

Solution: instead of aborting when the tick changes, fall back to the
current cache's hunks that have a resolved `lang` field. This allows
the deferred syntax pass to apply treesitter highlighting even after
the ft retry invalidation cycle.
@barrettruth barrettruth merged commit 9e077cf into main Mar 20, 2026
3 checks passed
@barrettruth barrettruth deleted the fix/deferred-syntax-stale branch March 20, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant