Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cb9b7d9e
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,发现更多精彩内容 >>
提交
cb9b7d9e
编写于
1月 31, 2017
作者:
D
David Poeschl
提交者:
GitHub
1月 31, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16826 from dpoeschl/FixRenameReentrancy2
Inline Rename: Prevent crash when source control dialogs show
上级
bc44e42f
1bbe244b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
15 deletion
+44
-15
src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.cs
...s/Core/Implementation/InlineRename/InlineRenameSession.cs
+44
-15
未找到文件。
src/EditorFeatures/Core/Implementation/InlineRename/InlineRenameSession.cs
浏览文件 @
cb9b7d9e
...
...
@@ -256,6 +256,7 @@ private void UpdateReferenceLocationsTask(Task<IInlineRenameLocationSet> allRena
ForegroundTaskScheduler
).
CompletesAsyncOperation
(
asyncToken
);
UpdateConflictResolutionTask
();
QueueApplyReplacements
();
}
public
Workspace
Workspace
{
get
{
return
_workspace
;
}
}
...
...
@@ -382,10 +383,15 @@ internal void ApplyReplacementText(string replacementText, bool propagateEditImm
VerifyNotDismissed
();
this
.
ReplacementText
=
replacementText
;
var
asyncToken
=
_asyncListener
.
BeginAsyncOperation
(
nameof
(
ApplyReplacementText
));
Action
propagateEditAction
=
delegate
{
AssertIsForeground
();
if
(
_dismissed
)
{
asyncToken
.
Dispose
();
return
;
}
...
...
@@ -399,8 +405,29 @@ internal void ApplyReplacementText(string replacementText, bool propagateEditImm
}
_isApplyingEdit
=
false
;
// We already kicked off UpdateConflictResolutionTask below (outside the delegate).
// Now that we are certain the replacement text has been propagated to all of the
// open buffers, it is safe to actually apply the replacements it has calculated.
// See https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=227513
QueueApplyReplacements
();
asyncToken
.
Dispose
();
};
// Start the conflict resolution task but do not apply the results immediately. The
// buffer changes performed in propagateEditAction can cause source control modal
// dialogs to show. Those dialogs pump, and yield the UI thread to whatever work is
// waiting to be done there, including our ApplyReplacements work. If ApplyReplacements
// starts running on the UI thread while propagateEditAction is still updating buffers
// on the UI thread, we crash because we try to enumerate the undo stack while an undo
// transaction is still in process. Therefore, we defer QueueApplyReplacements until
// after the buffers have been edited, and any modal dialogs have been completed.
// In addition to avoiding the crash, this also ensures that the resolved conflict text
// is applied after the simple text change is propagated.
// See https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=227513
UpdateConflictResolutionTask
();
if
(
propagateEditImmediately
)
{
propagateEditAction
();
...
...
@@ -410,8 +437,6 @@ internal void ApplyReplacementText(string replacementText, bool propagateEditImm
// When responding to a text edit, we delay propagating the edit until the first transaction completes.
Dispatcher
.
CurrentDispatcher
.
BeginInvoke
(
propagateEditAction
,
DispatcherPriority
.
Send
,
null
);
}
UpdateConflictResolutionTask
();
}
private
void
UpdateConflictResolutionTask
()
...
...
@@ -421,6 +446,8 @@ private void UpdateConflictResolutionTask()
_conflictResolutionTaskCancellationSource
.
Cancel
();
_conflictResolutionTaskCancellationSource
=
new
CancellationTokenSource
();
// If the replacement text is empty, we do not update the results of the conflict
// resolution task. We instead wait for a non-empty identifier.
if
(
this
.
ReplacementText
==
string
.
Empty
)
{
return
;
...
...
@@ -430,30 +457,32 @@ private void UpdateConflictResolutionTask()
var
optionSet
=
_optionSet
;
var
cancellationToken
=
_conflictResolutionTaskCancellationSource
.
Token
;
var
asyncToken
=
_asyncListener
.
BeginAsyncOperation
(
nameof
(
UpdateConflictResolutionTask
));
_conflictResolutionTask
=
_allRenameLocationsTask
.
SafeContinueWithFromAsync
(
t
=>
UpdateConflictResolutionTask
(
t
.
Result
,
replacementText
,
optionSet
,
cancellationToken
),
t
=>
t
.
Result
.
GetReplacementsAsync
(
replacementText
,
optionSet
,
cancellationToken
),
cancellationToken
,
TaskContinuationOptions
.
OnlyOnRanToCompletion
,
TaskScheduler
.
Default
);
var
asyncToken
=
_asyncListener
.
BeginAsyncOperation
(
"UpdateConflictResolutionTask"
);
_conflictResolutionTask
.
CompletesAsyncOperation
(
asyncToken
);
}
private
Task
<
IInlineRenameReplacementInfo
>
UpdateConflictResolutionTask
(
IInlineRenameLocationSet
locations
,
string
replacementText
,
OptionSet
optionSet
,
CancellationToken
cancellationToken
)
private
void
QueueApplyReplacements
(
)
{
var
conflictResolutionTask
=
Task
.
Run
(
async
()
=>
await
locations
.
GetReplacementsAsync
(
replacementText
,
optionSet
,
cancellationToken
).
ConfigureAwait
(
false
),
cancellationToken
);
var
asyncToken
=
_asyncListener
.
BeginAsyncOperation
(
"UpdateConflictResolutionTask"
);
conflictResolutionTask
.
SafeContinueWith
(
t
=>
ApplyReplacements
(
t
.
Result
,
cancellationToken
),
cancellationToken
,
// If the replacement text is empty, we do not update the results of the conflict
// resolution task. We instead wait for a non-empty identifier.
if
(
this
.
ReplacementText
==
string
.
Empty
)
{
return
;
}
var
asyncToken
=
_asyncListener
.
BeginAsyncOperation
(
nameof
(
QueueApplyReplacements
));
_conflictResolutionTask
.
SafeContinueWith
(
t
=>
ApplyReplacements
(
t
.
Result
,
_conflictResolutionTaskCancellationSource
.
Token
),
_conflictResolutionTaskCancellationSource
.
Token
,
TaskContinuationOptions
.
OnlyOnRanToCompletion
,
ForegroundTaskScheduler
).
CompletesAsyncOperation
(
asyncToken
);
return
conflictResolutionTask
;
}
private
void
ApplyReplacements
(
IInlineRenameReplacementInfo
replacementInfo
,
CancellationToken
cancellationToken
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录