提交 2f112131 编写于 作者: C CyrusNajmabadi

FindRefs 'preview' versus 'navigate to source location'.

上级 d01211ef
......@@ -53,7 +53,7 @@ internal static class IStreamingFindUsagesPresenterExtensions
var externalItems = definitions.WhereAsArray(d => d.IsExternal);
foreach (var item in externalItems)
{
if (item.TryNavigateTo())
if (item.TryNavigateTo(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();
return nonExternalItems[0].TryNavigateTo(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(
......
......@@ -29,7 +29,7 @@ internal sealed class DocumentLocationDefinitionItem : DefinitionItem
}
public override bool CanNavigateTo() => SourceSpans[0].CanNavigateTo();
public override bool TryNavigateTo() => SourceSpans[0].TryNavigateTo();
public override bool TryNavigateTo(bool isPreview) => SourceSpans[0].TryNavigateTo(isPreview);
}
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ private sealed class NonNavigatingDefinitionItem : DefinitionItem
}
public override bool CanNavigateTo() => false;
public override bool TryNavigateTo() => false;
public override bool TryNavigateTo(bool isPreview) => false;
}
}
}
\ No newline at end of file
......@@ -48,11 +48,11 @@ private sealed class MetadataDefinitionItem : DefinitionItem
public override bool CanNavigateTo()
=> TryNavigateTo((symbol, project, service) => true);
public override bool TryNavigateTo()
public override bool TryNavigateTo(bool isPreview)
{
return TryNavigateTo((symbol, project, service) =>
service.TryNavigateToSymbol(
symbol, project, project.Solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, true)));
symbol, project, project.Solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, isPreview)));
}
private bool TryNavigateTo(Func<ISymbol, Project, ISymbolNavigationService, bool> action)
......
......@@ -87,7 +87,7 @@ internal abstract partial class DefinitionItem
}
public abstract bool CanNavigateTo();
public abstract bool TryNavigateTo();
public abstract bool TryNavigateTo(bool isPreview);
public static DefinitionItem Create(
ImmutableArray<string> tags,
......
......@@ -108,7 +108,7 @@ private class ExternalDefinitionItem : DefinitionItem
public override bool CanNavigateTo() => true;
public override bool TryNavigateTo()
public override bool TryNavigateTo(bool isPreview)
{
return TryOpenFile() && TryNavigateToPosition();
}
......
......@@ -49,7 +49,7 @@ private string CreateDisplayText()
public override int GoToSource()
{
return _definitionItem.TryNavigateTo()
return _definitionItem.TryNavigateTo(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,9 +34,9 @@ private class RoslynDefinitionBucket : DefinitionBucket, ISupportsNavigation
DefinitionItem = definitionItem;
}
public bool TryNavigateTo()
public bool TryNavigateTo(bool isPreview)
{
return DefinitionItem.TryNavigateTo();
return DefinitionItem.TryNavigateTo(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.
先完成此消息的编辑!
想要评论请 注册