-
Notifications
You must be signed in to change notification settings - Fork 679
Honor parameter information setting for signature help #8581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Stella Huang (StellaHuang95)
merged 1 commit into
main
from
fix/8580-parameter-information
Jul 21, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...on/Product/PythonTools/PythonTools/LanguageServerClient/PythonSignatureHelpMiddleLayer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| using System; | ||
| using System.Globalization; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.PythonTools.Editor; | ||
| using Microsoft.VisualStudio.LanguageServer.Client; | ||
| using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
| using Newtonsoft.Json.Linq; | ||
|
|
||
| namespace Microsoft.PythonTools.LanguageServerClient { | ||
| #if !DEV18_OR_LATER | ||
| #pragma warning disable CS0618 | ||
| #endif | ||
| internal sealed class PythonSignatureHelpMiddleLayer : | ||
| #if DEV18_OR_LATER | ||
| ILanguageClientMiddleLayer2<JToken> { | ||
| #else | ||
| ILanguageClientMiddleLayer { | ||
| #endif | ||
| private LanguagePreferences _languagePreferences; | ||
|
|
||
| internal void Initialize(LanguagePreferences languagePreferences) { | ||
| Volatile.Write(ref _languagePreferences, languagePreferences ?? throw new ArgumentNullException(nameof(languagePreferences))); | ||
| } | ||
|
|
||
| public bool CanHandle(string methodName) => | ||
| string.Equals(methodName, Methods.TextDocumentSignatureHelpName, StringComparison.Ordinal); | ||
|
|
||
| public Task<JToken> HandleRequestAsync(string methodName, JToken methodParam, Func<JToken, Task<JToken>> sendRequest) { | ||
| if (ShouldSuppressAutomaticSignatureHelp(methodParam)) { | ||
| return Task.FromResult<JToken>(JValue.CreateNull()); | ||
| } | ||
|
|
||
| return sendRequest(methodParam); | ||
| } | ||
|
|
||
| public Task HandleNotificationAsync(string methodName, JToken methodParam, Func<JToken, Task> sendNotification) => | ||
| sendNotification(methodParam); | ||
|
|
||
| private bool ShouldSuppressAutomaticSignatureHelp(JToken methodParam) { | ||
| var languagePreferences = Volatile.Read(ref _languagePreferences); | ||
| if (languagePreferences == null || languagePreferences.AutoListParams) { | ||
| return false; | ||
| } | ||
|
|
||
| if (!(methodParam is JObject request) || | ||
| !(request["context"] is JObject context) || | ||
| context["triggerKind"]?.Type != JTokenType.Integer || | ||
| context["isRetrigger"]?.Type != JTokenType.Boolean || | ||
| context["isRetrigger"].Value<bool>() || | ||
| (context["activeSignatureHelp"] != null && context["activeSignatureHelp"].Type != JTokenType.Null)) { | ||
| return false; | ||
| } | ||
|
|
||
| if (!int.TryParse( | ||
| context["triggerKind"].ToString(), | ||
| NumberStyles.Integer, | ||
| CultureInfo.InvariantCulture, | ||
| out var triggerKind)) { | ||
| return false; | ||
| } | ||
|
|
||
| return triggerKind == (int)SignatureHelpTriggerKind.TriggerCharacter || | ||
| triggerKind == (int)SignatureHelpTriggerKind.ContentChange; | ||
| } | ||
| } | ||
| #if !DEV18_OR_LATER | ||
| #pragma warning restore CS0618 | ||
| #endif | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
...on/Product/PythonTools/PythonTools/Options/PythonAdvancedEditorOptionsControl.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add focused regression coverage for the signature-help suppression matrix. This predicate has several fail-open branches, and tests should distinguish disabled preferences for new automatic TriggerCharacter/ContentChange requests from explicit invocations, retriggers, active sessions, malformed contexts, and unavailable preferences.