make TreeSitterService a shared singleton
Each ClideCodeBlock and EditorView created its own TreeSitterService, each allocating a WASM engine, store, parser, and cursor via FFI. When widgets were disposed, multiple instances freeing the same underlying native resources caused double-free corruption on startup. Single shared instance for the app lifetime. Also fixes overlapping tree-sitter spans that caused duplicated text in code blocks — spans are now clipped to avoid re-emitting already-rendered characters. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,9 @@ class _LoadedGrammar {
|
||||
}
|
||||
|
||||
class TreeSitterService {
|
||||
static final TreeSitterService shared = TreeSitterService._();
|
||||
TreeSitterService._();
|
||||
|
||||
final Map<String, _LoadedGrammar> _grammars = {};
|
||||
final Set<String> _unavailable = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user