internal void RemoveTagger(SpellCheckerTagger tagger) { _activeTaggers.Remove(tagger); if (_activeTaggers.Count == 0) { // Last tagger was disposed of. This is means there are no longer any open views on the buffer so we can safely shut down // spell checking for that buffer. _buffer.ChangedLowPriority -= this.OnBufferChange; _provider.RemoveSpellChecker(this); _isDisposed = true; _buffer.Properties.RemoveProperty(typeof(SpellChecker)); IDisposable classifierDispose = _classifier as IDisposable; if (classifierDispose != null) { classifierDispose.Dispose(); } _classifier = null; } }
/// <summary> /// Create a tagger that does spell checking on the view/buffer combination. /// </summary> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { ITagger <T> tagger = null; // Only attempt to spell check on the view's edit buffer (and multiple views could have that buffer open simultaneously so // only create one instance of the spell checker. if ((buffer == textView.TextBuffer) && (typeof(T) == typeof(IErrorTag))) { var spellChecker = buffer.Properties.GetOrCreateSingletonProperty(typeof(SpellChecker), () => new SpellChecker(this, textView, buffer)); // This is a thin wrapper around the SpellChecker that can be disposed of without shutting down the SpellChecker // (unless it was the last tagger on the spell checker). tagger = new SpellCheckerTagger(spellChecker) as ITagger <T>; } return(tagger); }
internal void AddTagger(SpellCheckerTagger tagger) { _activeTaggers.Add(tagger); if (_activeTaggers.Count == 1) { // First tagger created ... start doing stuff. _classifier = _provider.ClassifierAggregatorService.GetClassifier(_buffer); _buffer.ChangedLowPriority += this.OnBufferChange; _dirtySpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(_currentSnapshot, 0, _currentSnapshot.Length)); _provider.AddSpellChecker(this); this.KickUpdate(); } }