Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
afcedeb5
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
afcedeb5
编写于
3月 02, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore original behavior of Shift+Enter during completion
Fixes #33823
上级
2cab0d70
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
42 addition
and
22 deletion
+42
-22
src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs
...p/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs
+3
-2
src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs
...CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs
+4
-2
src/EditorFeatures/Core/Implementation/AutomaticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
...ticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
+22
-1
src/EditorFeatures/TestUtilities/AutomaticCompletion/AbstractAutomaticLineEnderTests.cs
...es/AutomaticCompletion/AbstractAutomaticLineEnderTests.cs
+5
-11
src/EditorFeatures/VisualBasic/AutomaticCompletion/AutomaticLineEnderCommandHandler.vb
...c/AutomaticCompletion/AutomaticLineEnderCommandHandler.vb
+3
-2
src/EditorFeatures/VisualBasicTest/AutomaticCompletion/AutomaticLineEnderTests.vb
...lBasicTest/AutomaticCompletion/AutomaticLineEnderTests.vb
+4
-2
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpIntelliSense.cs
...grationTest/IntegrationTests/CSharp/CSharpIntelliSense.cs
+1
-2
未找到文件。
src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs
浏览文件 @
afcedeb5
...
...
@@ -34,8 +34,9 @@ internal class AutomaticLineEnderCommandHandler : AbstractAutomaticLineEnderComm
[
ImportingConstructor
]
public
AutomaticLineEnderCommandHandler
(
ITextUndoHistoryRegistry
undoRegistry
,
IEditorOperationsFactoryService
editorOperations
)
:
base
(
undoRegistry
,
editorOperations
)
IEditorOperationsFactoryService
editorOperations
,
IAsyncCompletionBroker
asyncCompletionBroker
)
:
base
(
undoRegistry
,
editorOperations
,
asyncCompletionBroker
)
{
}
...
...
src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs
浏览文件 @
afcedeb5
...
...
@@ -6,6 +6,7 @@
using
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.VisualStudio.Commanding
;
using
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion
;
using
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Roslyn.Test.Utilities
;
...
...
@@ -848,9 +849,10 @@ protected override Action CreateNextHandler(TestWorkspace workspace)
internal
override
IChainedCommandHandler
<
AutomaticLineEnderCommandArgs
>
CreateCommandHandler
(
ITextUndoHistoryRegistry
undoRegistry
,
IEditorOperationsFactoryService
editorOperations
)
IEditorOperationsFactoryService
editorOperations
,
IAsyncCompletionBroker
asyncCompletionBroker
)
{
return
new
AutomaticLineEnderCommandHandler
(
undoRegistry
,
editorOperations
);
return
new
AutomaticLineEnderCommandHandler
(
undoRegistry
,
editorOperations
,
asyncCompletionBroker
);
}
}
}
src/EditorFeatures/Core/Implementation/AutomaticCompletion/AbstractAutomaticLineEnderCommandHandler.cs
浏览文件 @
afcedeb5
...
...
@@ -8,6 +8,8 @@
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Commanding
;
using
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion
;
using
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
;
using
Microsoft.VisualStudio.Text.Operations
;
...
...
@@ -20,15 +22,18 @@ internal abstract class AbstractAutomaticLineEnderCommandHandler :
{
private
readonly
ITextUndoHistoryRegistry
_undoRegistry
;
private
readonly
IEditorOperationsFactoryService
_editorOperationsFactoryService
;
private
readonly
IAsyncCompletionBroker
_asyncCompletionBroker
;
public
string
DisplayName
=>
EditorFeaturesResources
.
Automatic_Line_Ender
;
public
AbstractAutomaticLineEnderCommandHandler
(
ITextUndoHistoryRegistry
undoRegistry
,
IEditorOperationsFactoryService
editorOperationsFactoryService
)
IEditorOperationsFactoryService
editorOperationsFactoryService
,
IAsyncCompletionBroker
asyncCompletionBroker
)
{
_undoRegistry
=
undoRegistry
;
_editorOperationsFactoryService
=
editorOperationsFactoryService
;
_asyncCompletionBroker
=
asyncCompletionBroker
;
}
/// <summary>
...
...
@@ -58,6 +63,22 @@ public VSCommanding.CommandState GetCommandState(AutomaticLineEnderCommandArgs a
public
void
ExecuteCommand
(
AutomaticLineEnderCommandArgs
args
,
Action
nextHandler
,
CommandExecutionContext
context
)
{
// Completion will only be active here if this command wasn't handled by the completion controller itself.
if
(
_asyncCompletionBroker
.
IsCompletionActive
(
args
.
TextView
))
{
var
session
=
_asyncCompletionBroker
.
GetSession
(
args
.
TextView
);
var
computedItems
=
session
.
GetComputedItems
(
context
.
OperationContext
.
UserCancellationToken
);
var
softSelection
=
computedItems
.
SuggestionItemSelected
||
computedItems
.
UsesSoftSelection
;
var
behavior
=
session
.
Commit
(
'\n'
,
context
.
OperationContext
.
UserCancellationToken
);
session
.
Dismiss
();
if
(
behavior
!=
CommitBehavior
.
CancelCommit
&&
!
softSelection
)
{
// Skip the automatic line handling in this case for behavior parity with legacy completion.
return
;
}
}
// get editor operation
var
operations
=
_editorOperationsFactoryService
.
GetEditorOperations
(
args
.
TextView
);
if
(
operations
==
null
)
...
...
src/EditorFeatures/TestUtilities/AutomaticCompletion/AbstractAutomaticLineEnderTests.cs
浏览文件 @
afcedeb5
// 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
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Editor.Host
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Commanding
;
using
Microsoft.VisualStudio.Language.Intellisense
;
using
Microsoft.VisualStudio.Language.Intellisense
.AsyncCompletion
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Moq
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.AutomaticCompletion
...
...
@@ -32,7 +24,8 @@ public abstract class AbstractAutomaticLineEnderTests
internal
abstract
IChainedCommandHandler
<
AutomaticLineEnderCommandArgs
>
CreateCommandHandler
(
ITextUndoHistoryRegistry
undoRegistry
,
IEditorOperationsFactoryService
editorOperations
);
IEditorOperationsFactoryService
editorOperations
,
IAsyncCompletionBroker
asyncCompletionBroker
);
protected
void
Test
(
string
expected
,
string
code
,
bool
completionActive
=
false
,
bool
assertNextHandlerInvoked
=
false
)
{
...
...
@@ -46,7 +39,8 @@ protected void Test(string expected, string code, bool completionActive = false,
var
commandHandler
=
CreateCommandHandler
(
GetExportedValue
<
ITextUndoHistoryRegistry
>(
workspace
),
GetExportedValue
<
IEditorOperationsFactoryService
>(
workspace
));
GetExportedValue
<
IEditorOperationsFactoryService
>(
workspace
),
GetExportedValue
<
IAsyncCompletionBroker
>(
workspace
));
commandHandler
.
ExecuteCommand
(
new
AutomaticLineEnderCommandArgs
(
view
,
buffer
),
assertNextHandlerInvoked
...
...
src/EditorFeatures/VisualBasic/AutomaticCompletion/AutomaticLineEnderCommandHandler.vb
浏览文件 @
afcedeb5
...
...
@@ -24,9 +24,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.AutomaticCompletion
<
ImportingConstructor
>
Friend
Sub
New
(
undoRegistry
As
ITextUndoHistoryRegistry
,
editorOperations
As
IEditorOperationsFactoryService
)
editorOperations
As
IEditorOperationsFactoryService
,
asyncCompletionBroker
As
IAsyncCompletionBroker
)
MyBase
.
New
(
undoRegistry
,
editorOperations
)
MyBase
.
New
(
undoRegistry
,
editorOperations
,
asyncCompletionBroker
)
End
Sub
Protected
Overrides
Sub
NextAction
(
editorOperation
As
IEditorOperations
,
nextAction
As
Action
)
...
...
src/EditorFeatures/VisualBasicTest/AutomaticCompletion/AutomaticLineEnderTests.vb
浏览文件 @
afcedeb5
...
...
@@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports
Microsoft.CodeAnalysis.Editor.VisualBasic.AutomaticCompletion
Imports
Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration
Imports
Microsoft.VisualStudio.Commanding
Imports
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion
Imports
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
Imports
Microsoft.VisualStudio.Text.Operations
...
...
@@ -245,10 +246,11 @@ End Module
Friend
Overrides
Function
CreateCommandHandler
(
undoRegistry
As
ITextUndoHistoryRegistry
,
editorOperations
As
IEditorOperationsFactoryService
editorOperations
As
IEditorOperationsFactoryService
,
asyncCompletionBroker
As
IAsyncCompletionBroker
)
As
IChainedCommandHandler
(
Of
AutomaticLineEnderCommandArgs
)
Return
New
AutomaticLineEnderCommandHandler
(
undoRegistry
,
editorOperations
)
Return
New
AutomaticLineEnderCommandHandler
(
undoRegistry
,
editorOperations
,
asyncCompletionBroker
)
End
Function
Protected
Overrides
Function
CreateNextHandler
(
workspace
As
TestWorkspace
)
As
Action
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpIntelliSense.cs
浏览文件 @
afcedeb5
...
...
@@ -250,8 +250,7 @@ void Main(string[] args)
assertCaretPosition
:
true
);
}
// 🐛 This should work with async completion, but currently does not.
[
ConditionalWpfFact
(
typeof
(
LegacyCompletionCondition
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
[
WorkItem
(
33823
,
"https://github.com/dotnet/roslyn/issues/33823"
)]
public
void
CommitOnShiftEnter
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录