/// <summary> /// Called by derived types to enqueue tags re-calculation request /// </summary> private void RecalculateTagsOnChanged(TaggerEventArgs e) { // First, cancel any previous requests (either still queued, or started). We no longer // want to continue it if new changes have come in. _workQueue.CancelCurrentWork(); RegisterNotification(RecomputeTagsForeground, (int)e.Delay.ComputeTimeDelay(_subjectBuffer).TotalMilliseconds, _workQueue.CancellationToken); }
public void OnDocumentChanged(Action onCompleted) { _workQueue.CancelCurrentWork(); var cancellationToken = _workQueue.CancellationToken; _workQueue.EnqueueBackgroundTask( async ct => { await UpdateCurrentSnapshotAsync(ct); onCompleted(); }, "BuildDiagnostics", 1000, cancellationToken); }
private void OnEventSourceChanged(object?sender, TaggerEventArgs args) { // First, notify anyone listening to us that something definitely changed. this.Changed?.Invoke(this, args); var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document == null) { return; } if (!document.SupportsSemanticModel) { return; } // Now, attempt to cancel any existing work to get the compilation for this project, and kick off a new // piece of work in the future to do so. Do this after a delay so we can appropriately throttle ourselves // if we hear about a flurry of notifications. _workQueue.CancelCurrentWork(); _workQueue.EnqueueBackgroundTask(async c => { await document.Project.GetCompilationAsync(c).ConfigureAwait(false); this.Changed?.Invoke(this, new TaggerEventArgs(_delay)); }, $"{nameof(CompilationAvailableTaggerEventSource)}.{nameof(OnEventSourceChanged)}", 500, _workQueue.CancellationToken); }
private void OnDocumentChanged(object sender, DocumentEventArgs e) { if (e.Document.Language != LanguageNames.ShaderLab) { return; } _workQueue.CancelCurrentWork(); _workQueue.EnqueueBackgroundTask( async ct => { // TODO: Figure out whether this is a destructive change. // TODO: Incremental updates. await UpdateBuffersAsync(e.Document, ct); }, "UpdateBuffers", _workQueue.CancellationToken); }
public void Disconnect() { _workQueue.AssertIsForeground(); _workQueue.CancelCurrentWork(remainCancelled: true); // Tell the interaction object to stop issuing events. _eventSource.Disconnect(); if (_dataSource.CaretChangeBehavior.HasFlag(TaggerCaretChangeBehavior.RemoveAllTagsOnCaretMoveOutsideOfTag)) { _textViewOpt.Caret.PositionChanged -= OnCaretPositionChanged; } if (_dataSource.TextChangeBehavior.HasFlag(TaggerTextChangeBehavior.TrackTextChanges)) { _subjectBuffer.Changed -= OnSubjectBufferChanged; } _eventSource.UIUpdatesPaused -= OnUIUpdatesPaused; _eventSource.UIUpdatesResumed -= OnUIUpdatesResumed; _eventSource.Changed -= OnEventSourceChanged; }
public void Disconnect() { _underlyingSource.Changed -= OnEventSourceChanged; _underlyingSource.Disconnect(); _workQueue.CancelCurrentWork(); }