Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
19010373
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,发现更多精彩内容 >>
未验证
提交
19010373
编写于
3月 12, 2019
作者:
I
Ivan Basov
提交者:
GitHub
3月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor completion: move references to EditorOperations from the new completion (#33774)
上级
c43de649
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
36 deletion
+29
-36
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs
...lementation/IntelliSense/AsyncCompletion/CommitManager.cs
+2
-29
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManagerProvider.cs
...ion/IntelliSense/AsyncCompletion/CommitManagerProvider.cs
+2
-5
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Commit.cs
...plementation/IntelliSense/Completion/Controller_Commit.cs
+25
-2
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManager.cs
浏览文件 @
19010373
...
...
@@ -15,7 +15,6 @@
using
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Roslyn.Utilities
;
using
AsyncCompletionData
=
Microsoft
.
VisualStudio
.
Language
.
Intellisense
.
AsyncCompletion
.
Data
;
using
RoslynCompletionItem
=
Microsoft
.
CodeAnalysis
.
Completion
.
CompletionItem
;
...
...
@@ -29,7 +28,6 @@ internal sealed class CommitManager : ForegroundThreadAffinitizedObject, IAsyncC
new
AsyncCompletionData
.
CommitResult
(
isHandled
:
false
,
AsyncCompletionData
.
CommitBehavior
.
None
);
private
readonly
RecentItemsManager
_recentItemsManager
;
private
readonly
IEditorOperationsFactoryService
_editorOperationsFactoryService
;
private
readonly
ITextView
_textView
;
public
IEnumerable
<
char
>
PotentialCommitCharacters
...
...
@@ -48,10 +46,9 @@ public IEnumerable<char> PotentialCommitCharacters
}
}
internal
CommitManager
(
ITextView
textView
,
RecentItemsManager
recentItemsManager
,
IThreadingContext
threadingContext
,
IEditorOperationsFactoryService
editorOperationsFactoryService
)
:
base
(
threadingContext
)
internal
CommitManager
(
ITextView
textView
,
RecentItemsManager
recentItemsManager
,
IThreadingContext
threadingContext
)
:
base
(
threadingContext
)
{
_recentItemsManager
=
recentItemsManager
;
_editorOperationsFactoryService
=
editorOperationsFactoryService
;
_textView
=
textView
;
}
...
...
@@ -182,8 +179,6 @@ internal CommitManager(ITextView textView, RecentItemsManager recentItemsManager
var
triggerSnapshotSpan
=
new
SnapshotSpan
(
triggerSnapshot
,
textChange
.
Span
.
ToSpan
());
var
mappedSpan
=
triggerSnapshotSpan
.
TranslateTo
(
subjectBuffer
.
CurrentSnapshot
,
SpanTrackingMode
.
EdgeInclusive
);
var
adjustedNewText
=
AdjustForVirtualSpace
(
textChange
,
view
,
_editorOperationsFactoryService
);
using
(
var
edit
=
subjectBuffer
.
CreateEdit
(
EditOptions
.
DefaultMinimalChange
,
reiteratedVersionNumber
:
null
,
editTag
:
null
))
{
edit
.
Replace
(
mappedSpan
.
Span
,
change
.
TextChange
.
NewText
);
...
...
@@ -211,7 +206,7 @@ internal CommitManager(ITextView textView, RecentItemsManager recentItemsManager
var
caretPositionInBuffer
=
view
.
GetCaretPoint
(
subjectBuffer
);
if
(
caretPositionInBuffer
.
HasValue
&&
mappedSpan
.
IntersectsWith
(
caretPositionInBuffer
.
Value
))
{
view
.
TryMoveCaretToAndEnsureVisible
(
new
SnapshotPoint
(
subjectBuffer
.
CurrentSnapshot
,
mappedSpan
.
Start
.
Position
+
adjusted
NewText
.
Length
));
view
.
TryMoveCaretToAndEnsureVisible
(
new
SnapshotPoint
(
subjectBuffer
.
CurrentSnapshot
,
mappedSpan
.
Start
.
Position
+
textChange
.
NewText
.
Length
));
}
else
{
...
...
@@ -318,27 +313,5 @@ internal static bool SendEnterThroughToEditor(CompletionRules rules, RoslynCompl
return
item
.
GetEntireDisplayText
()
==
textTypedSoFar
;
}
}
internal
static
string
AdjustForVirtualSpace
(
TextChange
textChange
,
ITextView
textView
,
IEditorOperationsFactoryService
editorOperationsFactoryService
)
{
var
newText
=
textChange
.
NewText
;
var
caretPoint
=
textView
.
Caret
.
Position
.
BufferPosition
;
var
virtualCaretPoint
=
textView
.
Caret
.
Position
.
VirtualBufferPosition
;
if
(
textChange
.
Span
.
IsEmpty
&&
textChange
.
Span
.
Start
==
caretPoint
&&
virtualCaretPoint
.
IsInVirtualSpace
)
{
// They're in virtual space and the text change is specified against the cursor
// position that isn't in virtual space. In this case, add the virtual spaces to the
// thing we're adding.
var
editorOperations
=
editorOperationsFactoryService
.
GetEditorOperations
(
textView
);
var
whitespace
=
editorOperations
.
GetWhitespaceForVirtualSpace
(
virtualCaretPoint
);
return
whitespace
+
newText
;
}
return
newText
;
}
}
}
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CommitManagerProvider.cs
浏览文件 @
19010373
...
...
@@ -6,7 +6,6 @@
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Microsoft.VisualStudio.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion
...
...
@@ -18,18 +17,16 @@ internal class CommitManagerProvider : IAsyncCompletionCommitManagerProvider
{
private
readonly
IThreadingContext
_threadingContext
;
private
readonly
RecentItemsManager
_recentItemsManager
;
private
readonly
IEditorOperationsFactoryService
_editorOperationsFactoryService
;
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
public
CommitManagerProvider
(
IThreadingContext
threadingContext
,
RecentItemsManager
recentItemsManager
,
IEditorOperationsFactoryService
editorOperationsFactoryService
)
public
CommitManagerProvider
(
IThreadingContext
threadingContext
,
RecentItemsManager
recentItemsManager
)
{
_threadingContext
=
threadingContext
;
_recentItemsManager
=
recentItemsManager
;
_editorOperationsFactoryService
=
editorOperationsFactoryService
;
}
IAsyncCompletionCommitManager
IAsyncCompletionCommitManagerProvider
.
GetOrCreate
(
ITextView
textView
)
=>
new
CommitManager
(
textView
,
_recentItemsManager
,
_threadingContext
,
_editorOperationsFactoryService
);
=>
new
CommitManager
(
textView
,
_recentItemsManager
,
_threadingContext
);
}
}
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Commit.cs
浏览文件 @
19010373
...
...
@@ -5,7 +5,6 @@
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.Completion
;
using
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Internal.Log
;
...
...
@@ -13,6 +12,8 @@
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Text.Shared.Extensions
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion
...
...
@@ -113,7 +114,7 @@ private CompletionProvider GetCompletionProvider(CompletionItem item)
var
mappedSpan
=
triggerSnapshotSpan
.
TranslateTo
(
this
.
SubjectBuffer
.
CurrentSnapshot
,
SpanTrackingMode
.
EdgeInclusive
);
var
adjustedNewText
=
CommitManager
.
AdjustForVirtualSpace
(
textChange
,
this
.
TextView
,
_editorOperationsFactoryService
);
var
adjustedNewText
=
AdjustForVirtualSpace
(
textChange
,
this
.
TextView
,
_editorOperationsFactoryService
);
var
editOptions
=
GetEditOptions
(
mappedSpan
,
adjustedNewText
);
// The immediate window is always marked read-only and the language service is
...
...
@@ -195,6 +196,28 @@ private CompletionProvider GetCompletionProvider(CompletionItem item)
this
.
MakeMostRecentItem
(
item
.
DisplayText
);
}
private
static
string
AdjustForVirtualSpace
(
TextChange
textChange
,
ITextView
textView
,
IEditorOperationsFactoryService
editorOperationsFactoryService
)
{
var
newText
=
textChange
.
NewText
;
var
caretPoint
=
textView
.
Caret
.
Position
.
BufferPosition
;
var
virtualCaretPoint
=
textView
.
Caret
.
Position
.
VirtualBufferPosition
;
if
(
textChange
.
Span
.
IsEmpty
&&
textChange
.
Span
.
Start
==
caretPoint
&&
virtualCaretPoint
.
IsInVirtualSpace
)
{
// They're in virtual space and the text change is specified against the cursor
// position that isn't in virtual space. In this case, add the virtual spaces to the
// thing we're adding.
var
editorOperations
=
editorOperationsFactoryService
.
GetEditorOperations
(
textView
);
var
whitespace
=
editorOperations
.
GetWhitespaceForVirtualSpace
(
virtualCaretPoint
);
return
whitespace
+
newText
;
}
return
newText
;
}
private
void
SetCaretPosition
(
int
desiredCaretPosition
)
{
// Now, move the caret to the right location.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录