Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a5c02e2c
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,发现更多精彩内容 >>
提交
a5c02e2c
编写于
9月 24, 2015
作者:
K
Kevin Halverson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5434 from KevinH-MS/master
Add null checks when calling IWpfTextView.TextViewModel...
上级
efb8d22f
c05e5336
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
5 deletion
+28
-5
src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetExpansionClient.cs
...Implementation/Snippets/AbstractSnippetExpansionClient.cs
+18
-3
src/VisualStudio/Core/Def/Implementation/Venus/VenusCommandFilter.cs
...tudio/Core/Def/Implementation/Venus/VenusCommandFilter.cs
+10
-2
未找到文件。
src/VisualStudio/Core/Def/Implementation/Snippets/AbstractSnippetExpansionClient.cs
浏览文件 @
a5c02e2c
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
...
...
@@ -365,6 +366,13 @@ public virtual bool TryHandleReturn()
public
virtual
bool
TryInsertExpansion
(
int
startPositionInSubjectBuffer
,
int
endPositionInSubjectBuffer
)
{
var
textViewModel
=
TextView
.
TextViewModel
;
if
(
textViewModel
==
null
)
{
Debug
.
Assert
(
TextView
.
IsClosed
);
return
false
;
}
int
startLine
=
0
;
int
startIndex
=
0
;
int
endLine
=
0
;
...
...
@@ -377,13 +385,13 @@ public virtual bool TryInsertExpansion(int startPositionInSubjectBuffer, int end
SnapshotSpan
dataBufferSpan
;
if
(!
TryGetSpanOnHigherBuffer
(
SubjectBuffer
.
CurrentSnapshot
.
GetSpan
(
startPositionInSubjectBuffer
,
endPositionInSubjectBuffer
-
startPositionInSubjectBuffer
),
TextView
.
T
extViewModel
.
DataBuffer
,
t
extViewModel
.
DataBuffer
,
out
dataBufferSpan
))
{
return
false
;
}
var
buffer
=
EditorAdaptersFactoryService
.
GetBufferAdapter
(
TextView
.
T
extViewModel
.
DataBuffer
);
var
buffer
=
EditorAdaptersFactoryService
.
GetBufferAdapter
(
t
extViewModel
.
DataBuffer
);
var
expansion
=
buffer
as
IVsExpansion
;
if
(
buffer
==
null
||
expansion
==
null
)
{
...
...
@@ -446,6 +454,13 @@ public int OnBeforeInsertion(IVsExpansionSession pSession)
public
int
OnItemChosen
(
string
pszTitle
,
string
pszPath
)
{
var
textViewModel
=
TextView
.
TextViewModel
;
if
(
textViewModel
==
null
)
{
Debug
.
Assert
(
TextView
.
IsClosed
);
return
VSConstants
.
E_FAIL
;
}
var
hr
=
VSConstants
.
S_OK
;
try
...
...
@@ -456,7 +471,7 @@ public int OnItemChosen(string pszTitle, string pszPath)
textSpan
.
iEndLine
=
textSpan
.
iStartLine
;
textSpan
.
iEndIndex
=
textSpan
.
iStartIndex
;
IVsExpansion
expansion
=
EditorAdaptersFactoryService
.
GetBufferAdapter
(
TextView
.
T
extViewModel
.
DataBuffer
)
as
IVsExpansion
;
IVsExpansion
expansion
=
EditorAdaptersFactoryService
.
GetBufferAdapter
(
t
extViewModel
.
DataBuffer
)
as
IVsExpansion
;
earlyEndExpansionHappened
=
false
;
hr
=
expansion
.
InsertNamedExpansion
(
pszTitle
,
pszPath
,
textSpan
,
this
,
LanguageServiceGuid
,
fShowDisambiguationUI
:
0
,
pSession
:
out
ExpansionSession
);
...
...
src/VisualStudio/Core/Def/Implementation/Venus/VenusCommandFilter.cs
浏览文件 @
a5c02e2c
...
...
@@ -53,12 +53,20 @@ public override int GetDataTipText(TextSpan[] pSpan, out string pbstrText)
return
VSConstants
.
E_INVALIDARG
;
}
var
textViewModel
=
WpfTextView
.
TextViewModel
;
if
(
textViewModel
==
null
)
{
Debug
.
Assert
(
WpfTextView
.
IsClosed
);
pbstrText
=
null
;
return
VSConstants
.
E_FAIL
;
}
// We need to map the TextSpan from the DataBuffer to our subject buffer. We'll
// only consider spans whose length matches our input span (which we expect to
// always be zero). This is to address the case where the position is on a seam
// and maps to multiple source spans.
// If there is not exactly one matching span, just return.
var
span
=
WpfTextView
.
T
extViewModel
.
DataBuffer
.
CurrentSnapshot
.
GetSpan
(
pSpan
[
0
]);
var
span
=
t
extViewModel
.
DataBuffer
.
CurrentSnapshot
.
GetSpan
(
pSpan
[
0
]);
var
spanLength
=
span
.
Length
;
Debug
.
Assert
(
spanLength
==
0
,
$"Expected zero length span (got '
{
spanLength
}
'."
);
var
subjectSpan
=
WpfTextView
.
BufferGraph
.
MapDownToBuffer
(
span
,
SpanTrackingMode
.
EdgeInclusive
,
_subjectBuffer
)
...
...
@@ -83,7 +91,7 @@ public override int GetDataTipText(TextSpan[] pSpan, out string pbstrText)
// take the span that intersects with the input span, since that's probably
// the one we care about.
// If there are no such spans, just return.
var
surfaceSpan
=
WpfTextView
.
BufferGraph
.
MapUpToBuffer
(
subjectSpan
,
SpanTrackingMode
.
EdgeInclusive
,
WpfTextView
.
T
extViewModel
.
DataBuffer
)
var
surfaceSpan
=
WpfTextView
.
BufferGraph
.
MapUpToBuffer
(
subjectSpan
,
SpanTrackingMode
.
EdgeInclusive
,
t
extViewModel
.
DataBuffer
)
.
SingleOrDefault
(
x
=>
x
.
IntersectsWith
(
span
));
if
(
surfaceSpan
==
default
(
SnapshotSpan
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录