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

Fix caret affinity in GetReferencedSymbolsToLeftOfCaretAsync #52245

Merged
merged 6 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ private bool TryInsertArgumentCompletionSnippet(SnapshotSpan triggerSpan, Snapsh
if (expansion.InsertSpecificExpansion(doc, textSpan, this, LanguageServiceGuid, pszRelativePath: null, out _state._expansionSession) == VSConstants.S_OK)
{
Debug.Assert(_state._expansionSession != null);
_state._methodNameForInsertFullMethodCall = methodName;
_state._methodNameForInsertFullMethodCall = methodSymbols.First().Name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd that we have two ways we get the method name, one from symbols (which is correct) and the other one which maybe isn't. Should we just initialize methodName this way on 535? Or if it's not the same sometimes, add a comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 One is the method name as it appears in source code, and the other is the method name as it appears in the symbol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soundsl ike we should prefer the former? (but i don't care much).

Debug.Assert(_state._method == null);

if (_signatureHelpControllerProvider.GetController(TextView, SubjectBuffer) is { } controller)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ public void Method()
VisualStudio.Editor.Verify.CurrentLineText("object.Equals(null$$)", assertCaretPosition: true);
}

[WpfFact]
public void TabTabCompleteNewObject()
{
SetUpEditor(@"
public class Test
{
public void Method()
{
var value = $$
}
}
");

VisualStudio.Editor.SendKeys("new obje");

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("var value = new object$$", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Workspace.WaitForAllAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.SignatureHelp);
VisualStudio.Editor.Verify.CurrentLineText("var value = new object($$)", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("var value = new object()$$", assertCaretPosition: true);
}

[WpfFact]
public void TabTabBeforeSemicolon()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ End Class
VisualStudio.Editor.Verify.CurrentLineText("Object.Equals(Nothing$$)", assertCaretPosition: true);
}

[WpfFact]
public void TabTabCompleteNewObject()
{
SetUpEditor(@"
Public Class Test
Public Sub Method()
Dim value = $$
End Sub
End Class
");

VisualStudio.Editor.SendKeys("New Obje");

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("Dim value = New Object$$", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Workspace.WaitForAllAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.SignatureHelp);
VisualStudio.Editor.Verify.CurrentLineText("Dim value = New Object($$)", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("Dim value = New Object()$$", assertCaretPosition: true);
}

[WpfFact]
public void TabTabCompletionWithArguments()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#nullable disable

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;

namespace Roslyn.VisualStudio.IntegrationTests.VisualBasic
{
Expand All @@ -24,9 +24,11 @@ public BasicAutomaticBraceCompletion(VisualStudioInstanceFactory instanceFactory
{
}

[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void Braces_InsertionAndTabCompleting()
[WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void Braces_InsertionAndTabCompleting(bool argumentCompletion)
{
VisualStudio.Workspace.SetArgumentCompletionSnippetsOption(argumentCompletion);

SetUpEditor(@"
Class C
Sub Goo()
Expand All @@ -42,7 +44,21 @@ End Sub
VirtualKey.Escape,
VirtualKey.Tab);

VisualStudio.Editor.Verify.CurrentLineText("Dim x = {New Object}$$", assertCaretPosition: true);
if (argumentCompletion)
{
VisualStudio.Editor.Verify.CurrentLineText("Dim x = {New Object($$)}", assertCaretPosition: true);
VisualStudio.Workspace.WaitForAllAsyncOperations(Helper.HangMitigatingTimeout, FeatureAttribute.SignatureHelp);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("Dim x = {New Object()$$}", assertCaretPosition: true);

VisualStudio.Editor.SendKeys(VirtualKey.Tab);
VisualStudio.Editor.Verify.CurrentLineText("Dim x = {New Object()}$$", assertCaretPosition: true);
}
else
{
VisualStudio.Editor.Verify.CurrentLineText("Dim x = {New Object}$$", assertCaretPosition: true);
}
}

[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
Expand Down