-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Hook brace-matching up to the 'responsive completion' editor option #76746
Hook brace-matching up to the 'responsive completion' editor option #76746
Conversation
@@ -47,6 +47,10 @@ internal partial class BraceCompletionSessionProvider( | |||
public bool TryCreateSession(ITextView textView, SnapshotPoint openingPoint, char openingBrace, char closingBrace, out IBraceCompletionSession session) | |||
{ | |||
_threadingContext.ThrowIfNotOnUIThread(); | |||
|
|||
var isResponsive = textView.Options.GetOptionValue(DefaultOptions.ResponsiveCompletionOptionId); | |||
var responsiveThreshold = isResponsive ? textView.Options.GetOptionValue(DefaultOptions.ResponsiveCompletionThresholdOptionId) : -1; |
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.
defaults for this are 'true + 250ms'.
// Brace completion is cancellable if the user has the 'responsive completion' option enabled. | ||
var cancellationTokenSource = new CancellationTokenSource(); | ||
if (_timeoutThreshold > 0) | ||
cancellationTokenSource.CancelAfter(_timeoutThreshold); |
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.
consider something like to encapsulate the cancellationtokensource usage:
var cancellationToken = GetCancellationToken();
...
CancellationToken GetCancellationToken()
{
if (_timeoutThreshold <= 0)
return CancellationToken.None;
var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.CancelAfter(_timeoutThreshold);
return cancellationTokenSource.Token;
}
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.
This way, if brace matching is taking too long, we can responsibly cancel it and unblock typing.