static void DisposeEditorModel(TextEditorModel editorModel) { if (editorModel == null) { return; } editorModel.Dispose(); }
void OnEditorOnDocumentChanged(object sender, EventArgs args) { try { DisposeEditorModel(_editorModel); DisposeTMModel(_tmModel); _editorModel = new TextEditorModel(_editor.TextArea.TextView, _editor.Document, _exceptionHandler); _tmModel = new TMModel(_editorModel); _tmModel.SetGrammar(_grammar); _transformer = GetOrCreateTransformer(); _transformer.SetModel(_editor.Document, _tmModel); _tmModel.AddModelTokensChangedListener(_transformer); } catch (Exception ex) { _exceptionHandler?.Invoke(ex); } }