-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a proper tool bar in Document Outline #68094
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca4f377
Use the expected tool bar for Document Outline
sharwell c858096
Show the current sort state as a pressed button
sharwell 2bce74c
Use platform search box for Document Outline
sharwell abf2e60
Persist the sort order
sharwell 3bb4a00
Bring items into view when they are selected
sharwell b54a0d1
Make sure tree view items have an accessibility name
sharwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineStrings.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,19 @@ | |
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Extensions; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Utilities; | ||
using Microsoft.CodeAnalysis.Internal.Log; | ||
using Microsoft.VisualStudio.Editor; | ||
using Microsoft.VisualStudio.LanguageServices.Implementation; | ||
using Microsoft.VisualStudio.LanguageServices.Utilities; | ||
using Microsoft.VisualStudio.PlatformUI; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Microsoft.VisualStudio.Text; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
using InternalUtilities = Microsoft.Internal.VisualStudio.PlatformUI.Utilities; | ||
using IOleCommandTarget = Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget; | ||
using OLECMD = Microsoft.VisualStudio.OLE.Interop.OLECMD; | ||
using OLECMDF = Microsoft.VisualStudio.OLE.Interop.OLECMDF; | ||
|
@@ -31,15 +27,17 @@ namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline | |
/// Interaction logic for DocumentOutlineView.xaml | ||
/// All operations happen on the UI thread for visual studio | ||
/// </summary> | ||
internal sealed partial class DocumentOutlineView : UserControl, IOleCommandTarget, IDisposable | ||
internal sealed partial class DocumentOutlineView : UserControl, IOleCommandTarget, IDisposable, IVsWindowSearch | ||
{ | ||
private readonly IThreadingContext _threadingContext; | ||
private readonly VsCodeWindowViewTracker _viewTracker; | ||
private readonly DocumentOutlineViewModel _viewModel; | ||
private readonly IVsToolbarTrayHost _toolbarTrayHost; | ||
private readonly IVsWindowSearchHost _windowSearchHost; | ||
|
||
public DocumentOutlineView( | ||
IVsUIShell4 uiShell, | ||
IVsWindowSearchHostFactory windowSearchHostFactory, | ||
IThreadingContext threadingContext, | ||
VsCodeWindowViewTracker viewTracker, | ||
DocumentOutlineViewModel viewModel) | ||
|
@@ -60,19 +58,20 @@ public DocumentOutlineView( | |
ErrorHandler.ThrowOnFailure(((IVsUIWpfElement)uiObject).GetFrameworkElement(out var frameworkElement)); | ||
Commands.Content = frameworkElement; | ||
|
||
_windowSearchHost = windowSearchHostFactory.CreateWindowSearchHost(SearchHost); | ||
_windowSearchHost.SetupSearch(this); | ||
|
||
viewTracker.CaretMovedOrActiveViewChanged += ViewTracker_CaretMovedOrActiveViewChanged; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_toolbarTrayHost.Close(); | ||
_windowSearchHost.TerminateSearch(); | ||
_viewTracker.CaretMovedOrActiveViewChanged -= ViewTracker_CaretMovedOrActiveViewChanged; | ||
_viewModel.Dispose(); | ||
} | ||
|
||
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) | ||
=> _viewModel.SearchText = SearchBox.Text; | ||
|
||
int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) | ||
{ | ||
if (pguidCmdGroup == Guids.RoslynGroupId) | ||
|
@@ -122,7 +121,7 @@ int IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] p | |
return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; | ||
} | ||
|
||
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) | ||
int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) | ||
{ | ||
if (pguidCmdGroup == Guids.RoslynGroupId) | ||
{ | ||
|
@@ -153,6 +152,45 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv | |
return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; | ||
} | ||
|
||
bool IVsWindowSearch.SearchEnabled => true; | ||
|
||
Guid IVsWindowSearch.Category => Guids.DocumentOutlineSearchCategoryId; | ||
|
||
IVsEnumWindowSearchFilters? IVsWindowSearch.SearchFiltersEnum => null; | ||
|
||
IVsEnumWindowSearchOptions? IVsWindowSearch.SearchOptionsEnum => null; | ||
|
||
IVsSearchTask IVsWindowSearch.CreateSearch(uint dwCookie, IVsSearchQuery pSearchQuery, IVsSearchCallback pSearchCallback) | ||
{ | ||
_viewModel.SearchText = pSearchQuery.SearchString; | ||
return new VsSearchTask(dwCookie, pSearchQuery, pSearchCallback); | ||
} | ||
|
||
void IVsWindowSearch.ClearSearch() | ||
{ | ||
_viewModel.SearchText = ""; | ||
} | ||
|
||
void IVsWindowSearch.ProvideSearchSettings(IVsUIDataSource pSearchSettings) | ||
{ | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.ControlMaxWidth, uint.MaxValue); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchStartType, (uint)VSSEARCHSTARTTYPE.SST_DELAYED); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchStartDelay, (uint)100); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchUseMRU, true); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.PrefixFilterMRUItems, false); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.MaximumMRUItems, (uint)25); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchWatermark, ServicesVSResources.Document_Outline_Search); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchPopupAutoDropdown, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this one do? |
||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.ControlBorderThickness, "1"); | ||
InternalUtilities.SetValue(pSearchSettings, SearchSettingsDataSource.PropertyNames.SearchProgressType, (uint)VSSEARCHPROGRESSTYPE.SPT_INDETERMINATE); | ||
} | ||
|
||
bool IVsWindowSearch.OnNavigationKeyDown(uint dwNavigationKey, uint dwModifiers) | ||
{ | ||
// By default we are not interesting in intercepting navigation keys, so return "not handled" | ||
return false; | ||
} | ||
|
||
private void UpdateSort(SortOption sortOption) | ||
{ | ||
_threadingContext.ThrowIfNotOnUIThread(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I've never seen this before.