Skip to content

Commit 3bf6ae4

Browse files
authored
Allow Razor completion items on deletion (#11991)
* We had very old code that explicitely prohibited Razor items from being returned on deletion. I tested it and it seems to work well now, so I am removing the code blocking us from returning Razor completion items on deletion. * Fixing up unit test to account for changed behavior
1 parent 47b1f17 commit 3bf6ae4

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionListProvider.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ internal static bool IsApplicableTriggerContext(CompletionContext context)
263263
return true;
264264
}
265265

266-
if (vsCompletionContext.InvokeKind == VSInternalCompletionInvokeKind.Deletion)
267-
{
268-
// We do not support providing completions on delete.
269-
return false;
270-
}
271-
272266
return true;
273267
}
274268
}

src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Completion/RazorCompletionListProviderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private static IRazorCompletionItemProvider[] GetCompletionProviders()
6262
];
6363

6464
[Fact]
65-
public void IsApplicableTriggerContext_Deletion_ReturnsFalse()
65+
public void IsApplicableTriggerContext_Deletion_ReturnsTrue()
6666
{
6767
// Arrange
6868
var completionContext = new VSInternalCompletionContext()
@@ -74,7 +74,7 @@ public void IsApplicableTriggerContext_Deletion_ReturnsFalse()
7474
var result = RazorCompletionListProvider.IsApplicableTriggerContext(completionContext);
7575

7676
// Assert
77-
Assert.False(result);
77+
Assert.True(result);
7878
}
7979

8080
[Fact]

src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/CompletionIntegrationTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,31 @@ public void IncrementCount()
562562
await TestServices.Editor.ValidateNoDiscoColorsAsync(HangMitigatingCancellationToken);
563563
}
564564

565+
[IdeFact]
566+
[WorkItem("https://github.com/dotnet/razor/issues/11565")]
567+
public async Task TagHelpers_Present_OnBackspace()
568+
{
569+
await TestServices.SolutionExplorer.AddFileAsync(
570+
RazorProjectConstants.BlazorProjectName,
571+
"Test.razor",
572+
"""
573+
<PageTitle>Test</PageTitle>
574+
""",
575+
open: true,
576+
ControlledHangMitigatingCancellationToken);
577+
578+
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken);
579+
580+
await TestServices.Editor.PlaceCaretAsync("<PageTitle", charsOffset: 1, ControlledHangMitigatingCancellationToken);
581+
TestServices.Input.Send("{BACKSPACE}");
582+
583+
var completionSession = await TestServices.Editor.WaitForCompletionSessionAsync(s_snippetTimeout, HangMitigatingCancellationToken);
584+
var items = completionSession?.GetComputedItems(HangMitigatingCancellationToken);
585+
586+
Assert.NotNull(items);
587+
Assert.Contains("PageTitle", items.Items.Select(i => i.DisplayText));
588+
}
589+
565590
private async Task VerifyTypeAndCommitCompletionAsync(string input, string output, string search, string[] stringsToType, char? commitChar = null, string? expectedSelectedItemLabel = null)
566591
{
567592
await TestServices.SolutionExplorer.AddFileAsync(

0 commit comments

Comments
 (0)