提交 40070152 编写于 作者: R Ravi Chande

Dismiss completion upon Select-All

上级 5e384fcf
......@@ -24,7 +24,8 @@ internal abstract class AbstractCompletionCommandHandler :
ICommandHandler<SurroundWithCommandArgs>,
ICommandHandler<AutomaticLineEnderCommandArgs>,
ICommandHandler<SaveCommandArgs>,
ICommandHandler<DeleteKeyCommandArgs>
ICommandHandler<DeleteKeyCommandArgs>,
ICommandHandler<SelectAllCommandArgs>
{
private readonly IAsyncCompletionService _completionService;
......@@ -309,5 +310,17 @@ public void ExecuteCommand(DeleteKeyCommandArgs args, Action nextHandler)
AssertIsForeground();
ExecuteCommandWorker(args, nextHandler);
}
public CommandState GetCommandState(SelectAllCommandArgs args, Func<CommandState> nextHandler)
{
AssertIsForeground();
return GetCommandStateWorker(args, nextHandler);
}
public void ExecuteCommand(SelectAllCommandArgs args, Action nextHandler)
{
AssertIsForeground();
ExecuteCommandWorker(args, nextHandler);
}
}
}
......@@ -454,6 +454,7 @@
<Compile Include="Implementation\Intellisense\Completion\Controller.Session_SetModelSelectedItem.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller.Session_Wait.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller_AutomaticLineEnder.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller_SelectAll.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller_Delete.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller_Backspace.cs" />
<Compile Include="Implementation\Intellisense\Completion\Controller_CaretPositionChanged.cs" />
......
......@@ -38,7 +38,8 @@ internal partial class Controller :
ICommandHandler<SurroundWithCommandArgs>,
ICommandHandler<AutomaticLineEnderCommandArgs>,
ICommandHandler<SaveCommandArgs>,
ICommandHandler<DeleteKeyCommandArgs>
ICommandHandler<DeleteKeyCommandArgs>,
ICommandHandler<SelectAllCommandArgs>
{
private static readonly object s_controllerPropertyKey = new object();
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Editor.Commands;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion
{
internal partial class Controller
{
CommandState ICommandHandler<SelectAllCommandArgs>.GetCommandState(SelectAllCommandArgs args, System.Func<CommandState> nextHandler)
{
AssertIsForeground();
return nextHandler();
}
void ICommandHandler<SelectAllCommandArgs>.ExecuteCommand(SelectAllCommandArgs args, Action nextHandler)
{
AssertIsForeground();
if (sessionOpt != null)
{
StopModelComputation();
}
nextHandler();
}
}
}
......@@ -340,6 +340,11 @@ public void SendSave(Action<SaveCommandArgs, Action> commandHandler, Action next
commandHandler(new SaveCommandArgs(TextView, SubjectBuffer), nextHandler);
}
public void SendSelectAll(Action<SelectAllCommandArgs, Action> commandHandler, Action nextHandler)
{
commandHandler(new SelectAllCommandArgs(TextView, SubjectBuffer), nextHandler);
}
#endregion
}
}
......@@ -1485,5 +1485,24 @@ class Program
state.AssertCompletionSession()
End Using
End Sub
<WorkItem(1659, "https://github.com/dotnet/roslyn/issues/1659")>
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Sub DismissOnSelectAllCommand()
Using state = TestState.CreateCSharpTestState(
<Document><![CDATA[
class C
{
void foo(int x)
{
$$]]></Document>)
' Note: the caret is at the file, so the Select All command's movement
' of the caret to the end of the selection isn't responsible for
' dismissing the session.
state.SendInvokeCompletionList()
state.SendSelectAll()
state.AssertNoCompletionSession()
End Using
End Sub
End Class
End Namespace
......@@ -233,6 +233,11 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
MyBase.SendSave(Sub(a, n) handler.ExecuteCommand(a, n), Sub() Return)
End Sub
Public Overloads Sub SendSelectAll()
Dim handler = DirectCast(CompletionCommandHandler, ICommandHandler(Of SelectAllCommandArgs))
MyBase.SendSelectAll(Sub(a, n) handler.ExecuteCommand(a, n), Sub() Return)
End Sub
Public Sub AssertNoCompletionSession(Optional block As Boolean = True)
If block Then
WaitForAsynchronousOperations()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册