Skip to content

Commit

Permalink
Merge pull request #34391 from sharwell/rename-to-discard
Browse files Browse the repository at this point in the history
Disable rename tracking when replacing with discard
  • Loading branch information
sharwell authored Mar 25, 2019
2 parents 7ab3b77 + 5a62920 commit 23aa56b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class CSharpRenameTrackingLanguageHeuristicsService : IRenameTra
{
public bool IsIdentifierValidForRenameTracking(string name)
{
return name != "var" && name != "dynamic";
return name != "var" && name != "dynamic" && name != "_";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,29 @@ class [|Cat|]$$
}
}

[WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)]
[WorkItem(34280, "https://github.com/dotnet/roslyn/issues/34280")]
public async Task RenameTrackingReplaceIdentifierWithDiscard()
{
var code = @"
class Class
{
int Method()
{
int i;
[|i|]$$ = Method();
rteurn 0;
}
}";
using (var state = RenameTrackingTestState.Create(code, LanguageNames.CSharp))
{
var textSpan = state.HostDocument.SelectedSpans.Single();
state.EditorOperations.ReplaceText(new Span(textSpan.Start, textSpan.Length), "_");
await state.AssertNoTag();
}
}

[WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameTrackingNotAfterInvoke()
Expand Down

0 comments on commit 23aa56b

Please sign in to comment.