Skip to content

Commit

Permalink
Remove encouragement from signature help
Browse files Browse the repository at this point in the history
This change stops the encouragement extension from displaying in
signature help documentation.

fixes #6
  • Loading branch information
jaredpar committed Jun 23, 2014
1 parent 216fc9b commit ab56320
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ local.properties
.settings/
.loadpath

# Roslyn generated folders
*.sln.ide/

# External tool builders
.externalToolBuilders/

Expand Down
2 changes: 2 additions & 0 deletions EncouragePackage/EncourageIntellisenseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ void OnSaved(Document document)
var triggerPoint = point.Snapshot.CreateTrackingPoint(point.Position, PointTrackingMode.Positive);
if (!provider.SignatureHelpBroker.IsSignatureHelpActive(textView))
{
textView.Properties.AddProperty(EncourageSignatureHelpSource.SessionKey, null);
session = provider.SignatureHelpBroker.TriggerSignatureHelp(textView, triggerPoint, true);
textView.Properties.RemoveProperty(EncourageSignatureHelpSource.SessionKey);
}
}

Expand Down
12 changes: 12 additions & 0 deletions EncouragePackage/EncourageSignatureHelpSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ internal Signature(ITrackingSpan trackingSpan, string content, string prettyPrin
}
}

/// <summary>
/// This object needs to be added as a key to the property bag of an ITextView where
/// encouragement should be applied. This prevents encouragement from being
/// introduced in places like signature overload.
/// </summary>
internal static readonly object SessionKey = new object();

readonly ITextBuffer subjectBuffer;
readonly IEncouragements encouragements;

Expand All @@ -78,6 +85,11 @@ public void Dispose()

public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
{
if (!session.TextView.Properties.ContainsProperty(SessionKey))
{
return;
}

// Map the trigger point down to our buffer.
var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
if (!subjectTriggerPoint.HasValue)
Expand Down

0 comments on commit ab56320

Please sign in to comment.