fix(treesitter) Set modeline=false in TSHighlighter:destroy (#32234)

Problem:  `TSHighlighter:destroy()` causes double-processing of the modeline
and failure of `b:undo_ftplugin`.

Solution: Disable modeline in `TSHighlighter:destroy()` by setting `modeline=false`
if executing `syntaxset` autocommands for the `FileType` event.

Co-authored-by: Daniel Petrovic <daniel.petrovic@ebcont.com>
This commit is contained in:
Daniel Petrovic 2025-01-29 09:02:49 +01:00 committed by GitHub
parent da0ae95349
commit 19f00bf32c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -160,7 +160,10 @@ function TSHighlighter:destroy()
vim.bo[self.bufnr].spelloptions = self.orig_spelloptions vim.bo[self.bufnr].spelloptions = self.orig_spelloptions
vim.b[self.bufnr].ts_highlight = nil vim.b[self.bufnr].ts_highlight = nil
if vim.g.syntax_on == 1 then if vim.g.syntax_on == 1 then
api.nvim_exec_autocmds('FileType', { group = 'syntaxset', buffer = self.bufnr }) api.nvim_exec_autocmds(
'FileType',
{ group = 'syntaxset', buffer = self.bufnr, modeline = false }
)
end end
end end
end end