提交 313bfb28 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #18894 from CyrusNajmabadi/findRefsNavigation

FindRefs 'preview' versus 'navigate to source location'.
......@@ -53,7 +53,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
var externalItems = definitions.WhereAsArray(d => d.IsExternal);
foreach (var item in externalItems)
{
if (item.TryNavigateTo(workspace))
if (item.TryNavigateTo(workspace, isPreview: true))
{
return true;
}
......@@ -69,7 +69,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
nonExternalItems[0].SourceSpans.Length <= 1)
{
// There was only one location to navigate to. Just directly go to that location.
return nonExternalItems[0].TryNavigateTo(workspace);
return nonExternalItems[0].TryNavigateTo(workspace, isPreview: true);
}
if (presenter != null)
......
......@@ -52,13 +52,13 @@ public static bool CanNavigateTo(this DocumentSpan documentSpan)
return service.CanNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan);
}
public static bool TryNavigateTo(this DocumentSpan documentSpan)
public static bool TryNavigateTo(this DocumentSpan documentSpan, bool isPreview)
{
var solution = documentSpan.Document.Project.Solution;
var workspace = solution.Workspace;
var service = workspace.Services.GetService<IDocumentNavigationService>();
return service.TryNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan,
options: solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true));
options: solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, isPreview));
}
public static async Task<bool> IsHiddenAsync(
......
......@@ -49,7 +49,7 @@ public override bool CanNavigateTo(Workspace workspace)
return SourceSpans[0].CanNavigateTo();
}
public override bool TryNavigateTo(Workspace workspace)
public override bool TryNavigateTo(Workspace workspace, bool isPreview)
{
if (this.Properties.ContainsKey(NonNavigable))
{
......@@ -61,7 +61,7 @@ public override bool TryNavigateTo(Workspace workspace)
return TryNavigateToMetadataSymbol(workspace, symbolKey);
}
return SourceSpans[0].TryNavigateTo();
return SourceSpans[0].TryNavigateTo(isPreview);
}
private bool CanNavigateToMetadataSymbol(Workspace workspace, string symbolKey)
......
......@@ -116,7 +116,7 @@ internal abstract partial class DefinitionItem
}
public abstract bool CanNavigateTo(Workspace workspace);
public abstract bool TryNavigateTo(Workspace workspace);
public abstract bool TryNavigateTo(Workspace workspace, bool isPreview);
public static DefinitionItem Create(
ImmutableArray<string> tags,
......
......@@ -108,7 +108,7 @@ private class ExternalDefinitionItem : DefinitionItem
public override bool CanNavigateTo(Workspace workspace) => true;
public override bool TryNavigateTo(Workspace workspace)
public override bool TryNavigateTo(Workspace workspace, bool isPreview)
{
return TryOpenFile() && TryNavigateToPosition();
}
......
......@@ -52,7 +52,7 @@ private string CreateDisplayText()
public override int GoToSource()
{
return _definitionItem.TryNavigateTo(_workspace)
return _definitionItem.TryNavigateTo(_workspace, isPreview: true)
? VSConstants.S_OK
: VSConstants.E_FAIL;
}
......
......@@ -275,7 +275,11 @@ private static Document OpenDocument(Workspace workspace, DocumentId documentId,
{
if (options.GetOption(NavigationOptions.PreferProvisionalTab))
{
using (NewDocumentStateScope ndss = new NewDocumentStateScope(__VSNEWDOCUMENTSTATE.NDS_Provisional, VSConstants.NewDocumentStateReason.Navigation))
// If we're just opening the provisional tab, then do not "activate" the document
// (i.e. don't give it focus). This way if a user is just arrowing through a set
// of FindAllReferences results, they don't have their cursor placed into the document.
var state = __VSNEWDOCUMENTSTATE.NDS_Provisional | __VSNEWDOCUMENTSTATE.NDS_NoActivate;
using (var scope = new NewDocumentStateScope(state, VSConstants.NewDocumentStateReason.Navigation))
{
workspace.OpenDocument(documentId);
}
......
......@@ -33,7 +33,7 @@ public override void PreprocessNavigate(ITableEntryHandle entry, TableEntryNavig
var supportsNavigation = entry.Identity as ISupportsNavigation;
if (supportsNavigation != null)
{
if (supportsNavigation.TryNavigateTo())
if (supportsNavigation.TryNavigateTo(e.IsPreview))
{
e.Handled = true;
return;
......
......@@ -4,6 +4,6 @@ namespace Microsoft.VisualStudio.LanguageServices.FindUsages
{
internal interface ISupportsNavigation
{
bool TryNavigateTo();
bool TryNavigateTo(bool isPreview);
}
}
\ No newline at end of file
......@@ -34,8 +34,8 @@ private class RoslynDefinitionBucket : DefinitionBucket, ISupportsNavigation
DefinitionItem = definitionItem;
}
public bool TryNavigateTo()
=> DefinitionItem.TryNavigateTo(_presenter._workspace);
public bool TryNavigateTo(bool isPreview)
=> DefinitionItem.TryNavigateTo(_presenter._workspace, isPreview);
public override bool TryGetValue(string key, out object content)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册