Sync syntax from start

Syncing by block start patterns didn't restore states inside the
block, so syntax computed before a line was displayed, e.g. by
GetVueTag() or indent after jumping in a file, missed regions like a
multi-line css rule. This replaces the one-line block fix in the
previous commit.

Parsing from start takes ~190ms once for jumping to the end of a
6500-line file, and states are cached after that.
This commit is contained in:
leafOfTree committed 2026-10-20 01:18:18 +00:00
1 parent de812d609b
commit 2ed782e422
1 file changed
+3 -6
+3 -6
View File
@@ -124,12 +124,6 @@ function! s:SetSyntax(block, syntax, has_lang)
\.' end=+'.end.'+'
\.' keepend contains='.syntax_group.', vueTag'
" Don't sync to a block ending on the same line, like
" <style>p { color: red; }</style>
let sync_start = start.'\(.*'.end_tag.'\)\@!'
execute 'syntax sync match vueSync groupthere '.name.' +'.sync_start.'+'
execute 'syntax sync match vueSync groupthere NONE +'.end.'+'
" Block like <script src="...">...</script>
let oneline = start.'.*'.end_tag
execute 'syntax match '.name.' fold '
@@ -138,7 +132,10 @@ function! s:SetSyntax(block, syntax, has_lang)
endfunction
function! s:SetBlockSyntax(config_syntax)
" Parse from start, as syncing by block start doesn't restore states inside
" the block like a multi-line css rule
syntax sync clear
syntax sync fromstart
for [block, syntax] in items(a:config_syntax)
let type = type(syntax)