diff --git a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs index 9cbfd31e247ff..be9ddb850fc69 100644 --- a/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs +++ b/src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs @@ -156,6 +156,14 @@ private void OnTextViewClosed(object sender, EventArgs e) public async Task GetSuggestedActionCategoriesAsync( ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken) { + // This function gets called immediately after operations like scrolling. We want to wait just a small + // amount to ensure that we don't immediately start consuming CPU/memory which then impedes the very + // action the user is trying to perform. To accomplish this, we wait 100ms. That's longer than normal + // keyboard repeat rates (usually around 30ms), but short enough that it's not noticeable to the user. + await Task.Delay(100, cancellationToken).NoThrowAwaitable(); + if (cancellationToken.IsCancellationRequested) + return null; + using var state = _state.TryAddReference(); if (state is null) return null;