public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; if (!provider.Settings.RainbowToolTipsEnabled) { return; } SnapshotPoint?triggerPoint = session.GetTriggerPoint(textBuffer.CurrentSnapshot); if (!triggerPoint.HasValue) { return; } SnapshotPoint?otherBrace; if (!FindOtherBrace(triggerPoint.Value, out otherBrace)) { // triggerPoint is not a brace return; } if (!otherBrace.HasValue) { TextEditor.DisplayMessageInStatusBar("No matching brace found."); return; } if (IsTooClose(triggerPoint.Value, otherBrace.Value)) { return; } session.Dismissed += OnSessionDismissed; if (toolTipWindow == null) { toolTipWindow = this.provider.ToolTipProvider.CreateToolTip(session.TextView); toolTipWindow.SetSize(60, 5); } var span = new SnapshotSpan(triggerPoint.Value, 1); applicableToSpan = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgePositive); var element = toolTipWindow.GetWindow(otherBrace.Value); if (element != null) { quickInfoContent.Add(element); session.Set(new RainbowToolTipContext()); } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; if ( !provider.Settings.RainbowToolTipsEnabled ) { return; } SnapshotPoint? triggerPoint = session.GetTriggerPoint(textBuffer.CurrentSnapshot); if ( !triggerPoint.HasValue ) { return; } SnapshotPoint? otherBrace; if ( !FindOtherBrace(triggerPoint.Value, out otherBrace) ) { // triggerPoint is not a brace return; } if ( !otherBrace.HasValue ) { TextEditor.DisplayMessageInStatusBar("No matching brace found."); return; } if ( IsTooClose(triggerPoint.Value, otherBrace.Value) ) { return; } session.Dismissed += OnSessionDismissed; if ( toolTipWindow == null ) { toolTipWindow = this.provider.ToolTipProvider.CreateToolTip(session.TextView); toolTipWindow.SetSize(60, 5); } var span = new SnapshotSpan(triggerPoint.Value, 1); applicableToSpan = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgePositive); var element = toolTipWindow.GetWindow(otherBrace.Value); if ( element != null ) { quickInfoContent.Add(element); session.Set(new RainbowToolTipContext()); } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; if (!this.provider.Settings.RainbowToolTipsEnabled) { return; } SnapshotPoint?triggerPoint = session.GetTriggerPoint(this.textBuffer.CurrentSnapshot); if (!triggerPoint.HasValue) { return; } SnapshotPoint?otherBrace; if (!FindOtherBrace(triggerPoint.Value, out otherBrace)) { // triggerPoint is not a brace return; } if (!otherBrace.HasValue) { TextEditor.DisplayMessageInStatusBar("No matching brace found."); return; } if (IsTooClose(triggerPoint.Value, otherBrace.Value)) { return; } // IQuickInfoSession.Dismissed is never firing in VS2017 15.6 // so if the tooltip window still exists, kill it // and hope to god leaving IQuickInfoSession.Dismissed hooked // up doesn't end up in a memory leak if (this.toolTipWindow != null) { this.toolTipWindow.Dispose(); this.toolTipWindow = null; } session.Dismissed += OnSessionDismissed; if (this.toolTipWindow == null) { this.toolTipWindow = this.provider.ToolTipProvider.CreateToolTip(session.TextView); this.toolTipWindow.SetSize(60, 5); } var span = new SnapshotSpan(triggerPoint.Value, 1); applicableToSpan = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgePositive); var element = this.toolTipWindow.GetWindow(otherBrace.Value); if (element != null) { quickInfoContent.Add(element); session.Set(new RainbowToolTipContext()); } }