Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bbdcb30f
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,发现更多精彩内容 >>
未验证
提交
bbdcb30f
编写于
7月 09, 2020
作者:
D
David Wengier
提交者:
GitHub
7月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Plumb through should activate (#45641)
上级
97501b04
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
35 addition
and
71 deletion
+35
-71
src/EditorFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
...orFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
+2
-2
src/Features/Core/Portable/DocumentSpanExtensions.cs
src/Features/Core/Portable/DocumentSpanExtensions.cs
+3
-3
src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs
...ndUsages/DefinitionItem.DocumentLocationDefinitionItem.cs
+2
-2
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
+1
-1
src/Features/Core/Portable/Navigation/NavigationOptions.cs
src/Features/Core/Portable/Navigation/NavigationOptions.cs
+3
-4
src/Features/Core/Portable/NavigationBehavior.cs
src/Features/Core/Portable/NavigationBehavior.cs
+0
-28
src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyDetail.cs
...e/Def/Implementation/CallHierarchy/CallHierarchyDetail.cs
+2
-1
src/VisualStudio/Core/Def/Implementation/FindReferences/Entries/MetadataDefinitionItemEntry.cs
...ion/FindReferences/Entries/MetadataDefinitionItemEntry.cs
+1
-2
src/VisualStudio/Core/Def/Implementation/FindReferences/RoslynDefinitionBucket.cs
...f/Implementation/FindReferences/RoslynDefinitionBucket.cs
+1
-2
src/VisualStudio/Core/Def/Implementation/FindReferences/VisualStudioDefinitionsAndReferencesFactory.cs
...References/VisualStudioDefinitionsAndReferencesFactory.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs
...eDataSource/AbstractTableControlEventProcessorProvider.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableEntriesSnapshot.cs
...mentation/TableDataSource/AbstractTableEntriesSnapshot.cs
+6
-5
src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs
...Def/Implementation/TableDataSource/TableEntriesFactory.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
...isualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
...entation/TableDataSource/VisualStudioBaseTodoListTable.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
...e/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentNavigationService.cs
...tation/Workspace/VisualStudioDocumentNavigationService.cs
+4
-11
未找到文件。
src/EditorFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
浏览文件 @
bbdcb30f
...
...
@@ -74,7 +74,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
// If we're directly going to a location we need to activate the preview so
// that focus follows to the new cursor position. This behavior is expected
// because we are only going to navigate once successfully
if
(
item
.
TryNavigateTo
(
workspace
,
NavigationBehavior
.
PreviewWithFocus
))
if
(
item
.
TryNavigateTo
(
workspace
,
showInPreviewTab
:
true
,
activateTab
:
true
))
{
return
true
;
}
...
...
@@ -92,7 +92,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
// There was only one location to navigate to. Just directly go to that location. If we're directly
// going to a location we need to activate the preview so that focus follows to the new cursor position.
return
nonExternalItems
[
0
].
TryNavigateTo
(
workspace
,
NavigationBehavior
.
PreviewWithFocus
);
return
nonExternalItems
[
0
].
TryNavigateTo
(
workspace
,
showInPreviewTab
:
true
,
activateTab
:
true
);
}
if
(
presenter
!=
null
)
...
...
src/Features/Core/Portable/DocumentSpanExtensions.cs
浏览文件 @
bbdcb30f
...
...
@@ -17,14 +17,14 @@ public static bool CanNavigateTo(this DocumentSpan documentSpan)
return
service
.
CanNavigateToSpan
(
workspace
,
documentSpan
.
Document
.
Id
,
documentSpan
.
SourceSpan
);
}
public
static
bool
TryNavigateTo
(
this
DocumentSpan
documentSpan
,
NavigationBehavior
navigationBehavior
)
public
static
bool
TryNavigateTo
(
this
DocumentSpan
documentSpan
,
bool
showInPreviewTab
,
bool
activateTab
)
{
var
solution
=
documentSpan
.
Document
.
Project
.
Solution
;
var
workspace
=
solution
.
Workspace
;
var
service
=
workspace
.
Services
.
GetService
<
IDocumentNavigationService
>();
var
options
=
solution
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
navigationBehavior
!=
NavigationBehavior
.
Normal
);
options
=
options
.
WithChangedOption
(
NavigationOptions
.
Activate
ProvisionalTab
,
navigationBehavior
==
NavigationBehavior
.
PreviewWithFocus
);
var
options
=
solution
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
showInPreviewTab
);
options
=
options
.
WithChangedOption
(
NavigationOptions
.
Activate
Tab
,
activateTab
);
return
service
.
TryNavigateToSpan
(
workspace
,
documentSpan
.
Document
.
Id
,
documentSpan
.
SourceSpan
,
options
);
}
...
...
src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs
浏览文件 @
bbdcb30f
...
...
@@ -50,7 +50,7 @@ public override bool CanNavigateTo(Workspace workspace)
return
SourceSpans
[
0
].
CanNavigateTo
();
}
public
override
bool
TryNavigateTo
(
Workspace
workspace
,
NavigationBehavior
navigationBehavior
)
public
override
bool
TryNavigateTo
(
Workspace
workspace
,
bool
showInPreviewTab
,
bool
activateTab
)
{
if
(
Properties
.
ContainsKey
(
NonNavigable
))
{
...
...
@@ -62,7 +62,7 @@ public override bool TryNavigateTo(Workspace workspace, NavigationBehavior navig
return
TryNavigateToMetadataSymbol
(
workspace
,
symbolKey
);
}
return
SourceSpans
[
0
].
TryNavigateTo
(
navigationBehavior
);
return
SourceSpans
[
0
].
TryNavigateTo
(
showInPreviewTab
,
activateTab
);
}
private
bool
CanNavigateToMetadataSymbol
(
Workspace
workspace
,
string
symbolKey
)
...
...
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
浏览文件 @
bbdcb30f
...
...
@@ -154,7 +154,7 @@ internal abstract partial class DefinitionItem
}
public
abstract
bool
CanNavigateTo
(
Workspace
workspace
);
public
abstract
bool
TryNavigateTo
(
Workspace
workspace
,
NavigationBehavior
navigationBehavior
);
public
abstract
bool
TryNavigateTo
(
Workspace
workspace
,
bool
showInPreviewTab
,
bool
activateTab
);
public
static
DefinitionItem
Create
(
ImmutableArray
<
string
>
tags
,
...
...
src/Features/Core/Portable/Navigation/NavigationOptions.cs
浏览文件 @
bbdcb30f
...
...
@@ -15,10 +15,9 @@ internal static class NavigationOptions
public
static
readonly
Option2
<
bool
>
PreferProvisionalTab
=
new
Option2
<
bool
>(
nameof
(
NavigationOptions
),
nameof
(
PreferProvisionalTab
),
defaultValue
:
false
);
/// <summary>
/// This option can be passed to the <see cref="IDocumentNavigationService"/> APIs to request that if a provisional tab
/// <see cref="PreferProvisionalTab"/> is used the navigation should still activate the tab. Defaults to false to support
/// users not losing focus while navigating through lists such as find references.
/// This option can be passed to the <see cref="IDocumentNavigationService"/> APIs to request that the navigation should activate the tab.
/// The default for the platform is to activate the tab, so turning the option off tells the platform to not activate the tab.
/// </summary>
public
static
readonly
Option2
<
bool
>
Activate
ProvisionalTab
=
new
Option2
<
bool
>(
nameof
(
NavigationOptions
),
nameof
(
ActivateProvisionalTab
),
defaultValue
:
fals
e
);
public
static
readonly
Option2
<
bool
>
Activate
Tab
=
new
Option2
<
bool
>(
nameof
(
NavigationOptions
),
nameof
(
ActivateTab
),
defaultValue
:
tru
e
);
}
}
src/Features/Core/Portable/NavigationBehavior.cs
已删除
100644 → 0
浏览文件 @
97501b04
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
namespace
Microsoft.CodeAnalysis
{
internal
enum
NavigationBehavior
{
/// <summary>
/// The destination will attempt to open in a normal tab and activate
/// </summary>
Normal
,
/// <summary>
/// The destination will navigate using a preview window and not activate that window.
/// Useful for cases where the user might be going through a list of items and we want to
/// make the context visible but not make focus changes
/// </summary>
PreviewWithoutFocus
,
/// <summary>
/// The destination will navigate using a preview window and activate
/// </summary>
PreviewWithFocus
}
}
src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyDetail.cs
浏览文件 @
bbdcb30f
...
...
@@ -62,7 +62,8 @@ public void NavigateTo()
if
(
document
!=
null
)
{
var
navigator
=
_workspace
.
Services
.
GetService
<
IDocumentNavigationService
>();
var
options
=
_workspace
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
true
);
var
options
=
_workspace
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
true
)
.
WithChangedOption
(
NavigationOptions
.
ActivateTab
,
false
);
navigator
.
TryNavigateToSpan
(
_workspace
,
document
.
Id
,
_span
,
options
);
}
}
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/Entries/MetadataDefinitionItemEntry.cs
浏览文件 @
bbdcb30f
...
...
@@ -34,8 +34,7 @@ protected override object GetValueWorker(string keyName)
bool
ISupportsNavigation
.
TryNavigateTo
(
bool
isPreview
)
=>
DefinitionBucket
.
DefinitionItem
.
TryNavigateTo
(
Presenter
.
_workspace
,
isPreview
?
NavigationBehavior
.
PreviewWithoutFocus
:
NavigationBehavior
.
Normal
);
Presenter
.
_workspace
,
showInPreviewTab
:
isPreview
,
activateTab
:
!
isPreview
);
// Only activate the tab if not opening in preview
protected
override
IList
<
Inline
>
CreateLineTextInlines
()
=>
DefinitionBucket
.
DefinitionItem
.
DisplayParts
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/RoslynDefinitionBucket.cs
浏览文件 @
bbdcb30f
...
...
@@ -54,8 +54,7 @@ private class RoslynDefinitionBucket : DefinitionBucket, ISupportsNavigation
public
bool
TryNavigateTo
(
bool
isPreview
)
=>
DefinitionItem
.
TryNavigateTo
(
_presenter
.
_workspace
,
isPreview
?
NavigationBehavior
.
PreviewWithoutFocus
:
NavigationBehavior
.
Normal
);
_presenter
.
_workspace
,
showInPreviewTab
:
isPreview
,
activateTab
:
!
isPreview
);
// Only activate the tab if not opening in preview
public
override
bool
TryGetValue
(
string
key
,
out
object
content
)
{
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/VisualStudioDefinitionsAndReferencesFactory.cs
浏览文件 @
bbdcb30f
...
...
@@ -109,7 +109,7 @@ private class ExternalDefinitionItem : DefinitionItem
public
override
bool
CanNavigateTo
(
Workspace
workspace
)
=>
true
;
public
override
bool
TryNavigateTo
(
Workspace
workspace
,
NavigationBehavior
_
)
public
override
bool
TryNavigateTo
(
Workspace
workspace
,
bool
showInPreviewTab
,
bool
activateTab
)
=>
TryOpenFile
()
&&
TryNavigateToPosition
();
private
bool
TryOpenFile
()
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableControlEventProcessorProvider.cs
浏览文件 @
bbdcb30f
...
...
@@ -19,7 +19,7 @@ protected virtual EventProcessor CreateEventProcessor()
protected
class
EventProcessor
:
TableControlEventProcessorBase
{
protected
static
AbstractTableEntriesSnapshot
<
TItem
>
GetEntriesSnapshot
(
ITableEntryHandle
entryHandle
)
=>
GetEntriesSnapshot
(
entryHandle
,
out
var
index
);
=>
GetEntriesSnapshot
(
entryHandle
,
out
_
);
protected
static
AbstractTableEntriesSnapshot
<
TItem
>
GetEntriesSnapshot
(
ITableEntryHandle
entryHandle
,
out
int
index
)
{
...
...
@@ -44,7 +44,7 @@ public override void PreprocessNavigate(ITableEntryHandle entryHandle, TableEntr
// we might fail to navigate if we don't see the document in our solution anymore.
// that can happen if error is staled build error or user used #line pragma in C#
// to point to some random file in error or more.
e
.
Handled
=
roslynSnapshot
.
TryNavigateTo
(
index
,
e
.
IsPreview
);
e
.
Handled
=
roslynSnapshot
.
TryNavigateTo
(
index
,
e
.
IsPreview
,
e
.
ShouldActivate
);
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableEntriesSnapshot.cs
浏览文件 @
bbdcb30f
...
...
@@ -35,7 +35,7 @@ protected AbstractTableEntriesSnapshot(int version, ImmutableArray<TItem> items,
_trackingPoints
=
trackingPoints
;
}
public
abstract
bool
TryNavigateTo
(
int
index
,
bool
previewTab
);
public
abstract
bool
TryNavigateTo
(
int
index
,
bool
previewTab
,
bool
activate
);
public
abstract
bool
TryGetValue
(
int
index
,
string
columnName
,
out
object
content
);
public
int
VersionNumber
...
...
@@ -148,7 +148,7 @@ private static LinePosition GetLinePosition(ITextSnapshot snapshot, ITrackingPoi
return
new
LinePosition
(
line
.
LineNumber
,
point
.
Position
-
line
.
Start
);
}
protected
static
bool
TryNavigateTo
(
Workspace
workspace
,
DocumentId
documentId
,
LinePosition
position
,
bool
previewTab
)
protected
static
bool
TryNavigateTo
(
Workspace
workspace
,
DocumentId
documentId
,
LinePosition
position
,
bool
previewTab
,
bool
activate
)
{
var
navigationService
=
workspace
.
Services
.
GetService
<
IDocumentNavigationService
>();
if
(
navigationService
==
null
)
...
...
@@ -156,7 +156,8 @@ protected static bool TryNavigateTo(Workspace workspace, DocumentId documentId,
return
false
;
}
var
options
=
workspace
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
previewTab
);
var
options
=
workspace
.
Options
.
WithChangedOption
(
NavigationOptions
.
PreferProvisionalTab
,
previewTab
)
.
WithChangedOption
(
NavigationOptions
.
ActivateTab
,
activate
);
if
(
navigationService
.
TryNavigateToLineAndOffset
(
workspace
,
documentId
,
position
.
Line
,
position
.
Character
,
options
))
{
return
true
;
...
...
@@ -165,7 +166,7 @@ protected static bool TryNavigateTo(Workspace workspace, DocumentId documentId,
return
false
;
}
protected
bool
TryNavigateToItem
(
int
index
,
bool
previewTab
)
protected
bool
TryNavigateToItem
(
int
index
,
bool
previewTab
,
bool
activate
)
{
var
item
=
GetItem
(
index
);
var
documentId
=
item
?.
DocumentId
;
...
...
@@ -195,7 +196,7 @@ protected bool TryNavigateToItem(int index, bool previewTab)
position
=
item
.
GetOriginalPosition
();
}
return
TryNavigateTo
(
workspace
,
documentId
,
position
,
previewTab
);
return
TryNavigateTo
(
workspace
,
documentId
,
position
,
previewTab
,
activate
);
}
protected
static
string
GetFileName
(
string
original
,
string
mapped
)
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs
浏览文件 @
bbdcb30f
...
...
@@ -196,7 +196,7 @@ public EmptySnapshot(int version)
{
}
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
)
=>
false
;
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
,
bool
activate
)
=>
false
;
public
override
bool
TryGetValue
(
int
index
,
string
columnName
,
out
object
content
)
{
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
浏览文件 @
bbdcb30f
...
...
@@ -417,8 +417,8 @@ private ErrorRank GetErrorRank(DiagnosticData item)
}
}
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
)
=>
TryNavigateToItem
(
index
,
previewTab
);
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
,
bool
activate
)
=>
TryNavigateToItem
(
index
,
previewTab
,
activate
);
#
region
IWpfTableEntriesSnapshot
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
浏览文件 @
bbdcb30f
...
...
@@ -280,8 +280,8 @@ private LinePosition GetLineColumn(TodoTableItem item)
item
.
Data
.
MappedColumn
);
}
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
)
=>
TryNavigateToItem
(
index
,
previewTab
);
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
,
bool
activate
)
=>
TryNavigateToItem
(
index
,
previewTab
,
activate
);
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
浏览文件 @
bbdcb30f
...
...
@@ -204,7 +204,7 @@ public override bool TryGetValue(int index, string columnName, out object conten
}
}
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
)
public
override
bool
TryNavigateTo
(
int
index
,
bool
previewTab
,
bool
activate
)
{
var
item
=
GetItem
(
index
);
if
(
item
?.
DocumentId
==
null
)
...
...
@@ -216,7 +216,7 @@ public override bool TryNavigateTo(int index, bool previewTab)
var
solution
=
item
.
Workspace
.
CurrentSolution
;
return
solution
.
ContainsDocument
(
documentId
)
&&
TryNavigateTo
(
item
.
Workspace
,
documentId
,
item
.
GetOriginalPosition
(),
previewTab
);
TryNavigateTo
(
item
.
Workspace
,
documentId
,
item
.
GetOriginalPosition
(),
previewTab
,
activate
);
}
private
DocumentId
GetProperDocumentId
(
DiagnosticTableItem
item
)
...
...
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentNavigationService.cs
浏览文件 @
bbdcb30f
...
...
@@ -341,18 +341,11 @@ private bool CanMapFromSecondaryBufferToPrimaryBuffer(Workspace workspace, Docum
private
IDisposable
OpenNewDocumentStateScope
(
OptionSet
options
)
{
if
(!
options
.
GetOption
(
NavigationOptions
.
PreferProvisionalTab
))
{
return
null
;
}
var
state
=
__VSNEWDOCUMENTSTATE
.
NDS_Provisional
;
var
state
=
options
.
GetOption
(
NavigationOptions
.
PreferProvisionalTab
)
?
__VSNEWDOCUMENTSTATE
.
NDS_Provisional
:
__VSNEWDOCUMENTSTATE
.
NDS_Permanent
;
// If we're just opening the provisional tab, then do not "activate" the document
// (i.e. don't give it focus) unless specifically requested.
// This way if a user is just arrowing through a set
// of FindAllReferences results, they don't have their cursor placed into the document.
if
(!
options
.
GetOption
(
NavigationOptions
.
ActivateProvisionalTab
))
if
(!
options
.
GetOption
(
NavigationOptions
.
ActivateTab
))
{
state
|=
__VSNEWDOCUMENTSTATE
.
NDS_NoActivate
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录