Skip to content
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

Enable new inline rename by default #62992

Merged
merged 12 commits into from
Aug 25, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

namespace Microsoft.CodeAnalysis.Editor.InlineRename
{
internal sealed class InlineRenameExperimentationOptions
internal sealed class InlineRenameUIOptions
{
public static readonly Option2<bool> UseInlineAdornment = new(
feature: "InlineRenameExperimentation",
feature: "InlineRename",
name: "UseInlineAdornment",
defaultValue: false,
storageLocation: new FeatureFlagStorageLocation("Roslyn.UseInlineAdornmentForRename"));
defaultValue: true,
storageLocation: new FeatureFlagStorageLocation("Roslyn.Rename_UseInlineAdornment"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void UpdateAdornments()
{
_dashboardColorUpdater?.UpdateColors();

var useInlineAdornment = _globalOptionService.GetOption(InlineRenameExperimentationOptions.UseInlineAdornment);
var useInlineAdornment = _globalOptionService.GetOption(InlineRenameUIOptions.UseInlineAdornment);
if (useInlineAdornment)
{
if (!_textView.HasAggregateFocus)
Expand Down
104 changes: 48 additions & 56 deletions src/EditorFeatures/Test2/Rename/InlineRenameTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
VerifyFileName(workspace, "BarTest1")
End Using
End Function
Expand Down Expand Up @@ -82,7 +82,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename

session.Commit()

Await VerifyTagsAreCorrect(workspace, "renamedtest")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -136,7 +136,7 @@ class [|Test1$$|]
textBuffer.Insert(selectedSpan, "<>")

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Test1<>")
Await VerifyTagsAreCorrect(workspace)
VerifyFileName(workspace, "Test1")
End Using
End Function
Expand Down Expand Up @@ -227,11 +227,11 @@ class Deconstructable

Await WaitForRename(workspace)

Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
VerifyFileName(workspace, "BarTest1")
End Using
End Function
Expand Down Expand Up @@ -260,11 +260,11 @@ class Deconstructable
Dim replacementText = renameTextPrefix + originalTextToRename
Await WaitForRename(workspace)

Await VerifyTagsAreCorrect(workspace, replacementText)
Await VerifyTagsAreCorrect(workspace)

session.Commit()

Await VerifyTagsAreCorrect(workspace, replacementText)
Await VerifyTagsAreCorrect(workspace)

If renameFile Then
If fileToRename Is Nothing Then
Expand Down Expand Up @@ -788,7 +788,7 @@ End Class

session.Commit()

Await VerifyTagsAreCorrect(workspace, "goodynamic")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -916,11 +916,11 @@ End Class

textBuffer.Insert(caretPosition, "Bar")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
Await VerifyNoRenameTrackingTags(renameTrackingTagger, workspace, document)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
VerifyFileName(workspace, "BarTest1")
End Using
End Function
Expand Down Expand Up @@ -950,11 +950,11 @@ End Class
textBuffer.Insert(caretPosition, "Bar")
Await WaitForRename(workspace)

Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
Await VerifyNoRenameTrackingTags(renameTrackingTagger, workspace, document)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
VerifyFileName(workspace, "BarTest1")
End Using
End Function
Expand Down Expand Up @@ -988,10 +988,10 @@ End Class

textBuffer.Insert(caretPosition, "Bar")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
Await VerifyNoRenameTrackingTags(renameTrackingTagger, workspace, document)
VerifyFileName(workspace, "BarTest1")
End Using
Expand Down Expand Up @@ -1026,7 +1026,7 @@ End Class

textBuffer.Insert(caretPosition, "Bar")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)

session.Cancel()
Await VerifyNoRenameTrackingTags(renameTrackingTagger, workspace, document)
Expand Down Expand Up @@ -1063,10 +1063,10 @@ End Class

textBuffer.Insert(caretPosition, "Bar")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "BarTest1")
Await VerifyTagsAreCorrect(workspace)
Await VerifyNoRenameTrackingTags(renameTrackingTagger, workspace, document)
VerifyFileName(workspace, "BarTest1")

Expand Down Expand Up @@ -1106,7 +1106,7 @@ End Class

session.Commit(previewChanges:=True)

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
Assert.True(previewService.Called)
Assert.Equal(String.Format(EditorFeaturesResources.Preview_Changes_0, EditorFeaturesResources.Rename), previewService.Title)
Assert.Equal(String.Format(EditorFeaturesResources.Rename_0_to_1_colon, "Goo", "BarGoo"), previewService.Description)
Expand Down Expand Up @@ -1137,28 +1137,20 @@ End Class
previewService.ReturnsNull = True

Dim session = StartSession(workspace)
' Type a bit in the file
Dim caretPosition = workspace.Documents.Single(Function(d) d.CursorPosition.HasValue).CursorPosition.Value
Dim textBuffer = workspace.Documents.Single().GetTextBuffer()

textBuffer.Insert(caretPosition, "Bar")

session.ApplyReplacementText("BarGoo", propagateEditImmediately:=True)
session.Commit(previewChanges:=True)

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
Assert.True(previewService.Called)

' Session should still be up; type some more
caretPosition = workspace.Documents.Single(Function(d) d.CursorPosition.HasValue).CursorPosition.Value
textBuffer.Insert(caretPosition, "Cat")
' Session should still be up
session.ApplyReplacementText("CatBarGoo", propagateEditImmediately:=True)

previewService.ReturnsNull = False
previewService.Called = False
session.Commit(previewChanges:=True)
Await VerifyTagsAreCorrect(workspace, "CatBarGoo")
Await VerifyTagsAreCorrect(workspace)
Assert.True(previewService.Called)

VerifyFileName(workspace, "Test1.cs")
End Using
End Function

Expand Down Expand Up @@ -1197,14 +1189,14 @@ End Class

textBuffer.Insert(caretPosition, "o")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Mo")
Await VerifyTagsAreCorrect(workspace)

textBuffer.Insert(caretPosition + 1, "w")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Mow")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Mow")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1242,14 +1234,14 @@ End Class

textBuffer.Insert(caretPosition, "a")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "ma")
Await VerifyTagsAreCorrect(workspace)

textBuffer.Insert(caretPosition + 1, "w")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "maw")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "maw")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1326,11 +1318,11 @@ class C
textBuffer.CurrentSnapshot.GetText())

' Rename should still be active
Await VerifyTagsAreCorrect(workspace, "xyz")
Await VerifyTagsAreCorrect(workspace)

textBuffer.Insert(caretPosition + 2, "q")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "xyzq")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1359,10 +1351,10 @@ class C

textBuffer.Insert(caretPosition, "a")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1391,10 +1383,10 @@ class C

textBuffer.Insert(caretPosition, "a")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1425,10 +1417,10 @@ class C

textBuffer.Insert(caretPosition, "a")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1459,10 +1451,10 @@ class C

textBuffer.Insert(caretPosition, "a")
Await WaitForRename(workspace)
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)

session.Commit()
Await VerifyTagsAreCorrect(workspace, "Ma")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1522,7 +1514,7 @@ End Module
textBuffer.Insert(caretPosition, "q")
session.Commit()

Await VerifyTagsAreCorrect(workspace, "qp")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1552,7 +1544,7 @@ End Module

session.Commit()

Await VerifyTagsAreCorrect(workspace, "x")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1596,7 +1588,7 @@ End Class

session.Commit()

Await VerifyTagsAreCorrect(workspace, "xield1")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1897,7 +1889,7 @@ class [|$$Test1|]
Dim committed = session.GetTestAccessor().CommitWorker(previewChanges:=False)
Assert.False(committed)

Await VerifyTagsAreCorrect(workspace, "Test1")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -1981,7 +1973,7 @@ class [|C|]

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -2011,7 +2003,7 @@ class [|C|]

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -2041,7 +2033,7 @@ class [|C|]

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -2076,7 +2068,7 @@ class [|C|]

session.Commit()

Await VerifyTagsAreCorrect(workspace, "BarGoo")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down Expand Up @@ -2107,7 +2099,7 @@ class [|C|]

session.Commit()

Await VerifyTagsAreCorrect(workspace, "Example")
Await VerifyTagsAreCorrect(workspace)
End Using
End Function

Expand Down
Loading