Skip to content

Commit 10a4edb

Browse files
Revert "Revert "Stop using the rename dashboard""
1 parent 9a37522 commit 10a4edb

File tree

40 files changed

+90
-591
lines changed

40 files changed

+90
-591
lines changed

src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ internal partial class RenameCommandHandler(
3838
IAsynchronousOperationListenerProvider asynchronousOperationListenerProvider)
3939
: AbstractRenameCommandHandler(threadingContext, renameService, globalOptionService, asynchronousOperationListenerProvider.GetListener(FeatureAttribute.Rename))
4040
{
41-
protected override bool AdornmentShouldReceiveKeyboardNavigation(ITextView textView)
42-
=> GetAdornment(textView) switch
43-
{
44-
RenameDashboard dashboard => dashboard.ShouldReceiveKeyboardNavigation,
45-
RenameFlyout => true, // Always receive keyboard navigation for the inline adornment
46-
_ => false
47-
};
48-
4941
protected override void SetFocusToTextView(ITextView textView)
5042
{
5143
(textView as IWpfTextView)?.VisualElement.Focus();
@@ -59,22 +51,6 @@ protected override void SetFocusToAdornment(ITextView textView)
5951
}
6052
}
6153

62-
protected override void SetAdornmentFocusToNextElement(ITextView textView)
63-
{
64-
if (GetAdornment(textView) is RenameDashboard dashboard)
65-
{
66-
dashboard.FocusNextElement();
67-
}
68-
}
69-
70-
protected override void SetAdornmentFocusToPreviousElement(ITextView textView)
71-
{
72-
if (GetAdornment(textView) is RenameDashboard dashboard)
73-
{
74-
dashboard.FocusNextElement();
75-
}
76-
}
77-
7854
private static InlineRenameAdornment? GetAdornment(ITextView textView)
7955
{
8056
// If our adornment layer somehow didn't get composed, GetAdornmentLayer will throw.

src/EditorFeatures/Core.Wpf/InlineRename/UI/Adornment/RenameFlyout.xaml.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@ internal partial class RenameFlyout : InlineRenameAdornment
2626
private const int DefaultMinWidth = 200;
2727

2828
private readonly RenameFlyoutViewModel _viewModel;
29-
private readonly IEditorFormatMap _editorFormatMap;
3029
private readonly IWpfTextView _textView;
31-
private readonly IWpfThemeService? _wpfThemeService;
3230
private readonly IAsyncQuickInfoBroker _asyncQuickInfoBroker;
3331
private readonly IAsynchronousOperationListener _listener;
3432
private readonly IThreadingContext _threadingContext;
3533

3634
public RenameFlyout(
3735
RenameFlyoutViewModel viewModel,
3836
IWpfTextView textView,
39-
IWpfThemeService? themeService,
4037
IAsyncQuickInfoBroker asyncQuickInfoBroker,
41-
IEditorFormatMapService editorFormatMapService,
4238
IThreadingContext threadingContext,
4339
IAsynchronousOperationListenerProvider listenerProvider)
4440
{
@@ -50,11 +46,11 @@ public RenameFlyout(
5046
_textView.ViewportWidthChanged += TextView_ViewPortChanged;
5147
_listener = listenerProvider.GetListener(FeatureAttribute.InlineRenameFlyout);
5248
_threadingContext = threadingContext;
53-
_wpfThemeService = themeService;
5449

5550
RenameUserInput = _viewModel.SmartRenameViewModel is null ? new RenameUserInputTextBox(_viewModel) : new SmartRenameUserInputComboBox(_viewModel);
5651

5752
// On load focus the first tab target
53+
var token1 = _listener.BeginAsyncOperation(nameof(RenameUserInput.GotFocus));
5854
Loaded += (s, e) =>
5955
{
6056
// Wait until load to position adornment for space negotiation
@@ -64,6 +60,7 @@ public RenameFlyout(
6460
RenameUserInput.SelectText(_viewModel.StartingSelection.Start, _viewModel.StartingSelection.Length);
6561
RenameUserInput.TextSelectionChanged += RenameUserInput_TextSelectionChanged;
6662
RenameUserInput.GotFocus += RenameUserInput_GotFocus;
63+
token1.Dispose();
6764
};
6865

6966
InitializeComponent();
@@ -79,14 +76,12 @@ public RenameFlyout(
7976
MainPanel.Children.Insert(index + 1, smartRenameControl);
8077
}
8178

82-
_editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
83-
8479
// Dismiss any current tooltips. Note that this does not disable tooltips
8580
// from showing up again, so if a user has the mouse unmoved another
8681
// tooltip will pop up. https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1611398
8782
// tracks when we can handle this with IFeaturesService in VS
88-
var token = _listener.BeginAsyncOperation(nameof(DismissToolTipsAsync));
89-
_ = DismissToolTipsAsync().CompletesAsyncOperation(token);
83+
var token2 = _listener.BeginAsyncOperation(nameof(DismissToolTipsAsync));
84+
_ = DismissToolTipsAsync().CompletesAsyncOperation(token2);
9085
}
9186

9287
internal IRenameUserInput RenameUserInput { get; }

src/EditorFeatures/Core.Wpf/InlineRename/UI/InlineRenameAdornmentManager.cs

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Linq;
77
using System.Runtime.CompilerServices;
88
using Microsoft.CodeAnalysis;
9-
using Microsoft.CodeAnalysis.Editor.InlineRename;
109
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
1110
using Microsoft.CodeAnalysis.EditorFeatures.Lightup;
1211
using Microsoft.CodeAnalysis.Internal.Log;
@@ -20,15 +19,14 @@
2019

2120
namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
2221
{
23-
internal class InlineRenameAdornmentManager : IDisposable
22+
internal sealed class InlineRenameAdornmentManager : IDisposable
2423
{
2524
private readonly IWpfTextView _textView;
2625
private readonly IGlobalOptionService _globalOptionService;
2726
private readonly IWpfThemeService? _themeService;
2827
private readonly IAsyncQuickInfoBroker _asyncQuickInfoBroker;
2928
private readonly IAsynchronousOperationListenerProvider _listenerProvider;
3029
private readonly InlineRenameService _renameService;
31-
private readonly IEditorFormatMapService _editorFormatMapService;
3230
private readonly IInlineRenameColorUpdater? _dashboardColorUpdater;
3331
private readonly IThreadingContext _threadingContext;
3432
#pragma warning disable CS0618 // Editor team use Obsolete attribute to mark potential changing API
@@ -42,7 +40,6 @@ internal class InlineRenameAdornmentManager : IDisposable
4240

4341
public InlineRenameAdornmentManager(
4442
InlineRenameService renameService,
45-
IEditorFormatMapService editorFormatMapService,
4643
IInlineRenameColorUpdater? dashboardColorUpdater,
4744
IWpfTextView textView,
4845
IGlobalOptionService globalOptionService,
@@ -55,7 +52,6 @@ public InlineRenameAdornmentManager(
5552
#pragma warning restore CS0618
5653
{
5754
_renameService = renameService;
58-
_editorFormatMapService = editorFormatMapService;
5955
_dashboardColorUpdater = dashboardColorUpdater;
6056
_textView = textView;
6157
_globalOptionService = globalOptionService;
@@ -118,59 +114,43 @@ private void UpdateAdornments()
118114
return null;
119115
}
120116

121-
var useInlineAdornment = _globalOptionService.GetOption(InlineRenameUIOptionsStorage.UseInlineAdornment);
122-
LogAdornmentChoice(useInlineAdornment);
123-
if (useInlineAdornment)
117+
if (!_textView.HasAggregateFocus)
124118
{
125-
if (!_textView.HasAggregateFocus)
126-
{
127-
// For the rename flyout, the adornment is dismissed on focus lost. There's
128-
// no need to keep an adornment on every textview for show/hide behaviors
129-
return null;
130-
}
131-
132-
// Get the active selection to make sure the rename text is selected in the same way
133-
var originalSpan = _renameService.ActiveSession.TriggerSpan;
134-
var selectionSpan = _textView.Selection.SelectedSpans.First();
135-
136-
var start = selectionSpan.IsEmpty
137-
? 0
138-
: selectionSpan.Start - originalSpan.Start; // The length from the identifier to the start of selection
139-
140-
var length = selectionSpan.IsEmpty
141-
? originalSpan.Length
142-
: selectionSpan.Length;
143-
144-
var identifierSelection = new TextSpan(start, length);
145-
146-
var adornment = new RenameFlyout(
147-
(RenameFlyoutViewModel)s_createdViewModels.GetValue(
148-
_renameService.ActiveSession,
149-
session => new RenameFlyoutViewModel(session,
150-
identifierSelection,
151-
registerOleComponent: true,
152-
_globalOptionService,
153-
_threadingContext,
154-
_listenerProvider,
155-
_smartRenameSessionFactory)),
156-
_textView,
157-
_themeService,
158-
_asyncQuickInfoBroker,
159-
_editorFormatMapService,
160-
_threadingContext,
161-
_listenerProvider);
162-
163-
return adornment;
119+
// For the rename flyout, the adornment is dismissed on focus lost. There's
120+
// no need to keep an adornment on every textview for show/hide behaviors
121+
return null;
164122
}
165-
else
166-
{
167-
var newAdornment = new RenameDashboard(
168-
(RenameDashboardViewModel)s_createdViewModels.GetValue(_renameService.ActiveSession, session => new RenameDashboardViewModel(session, _threadingContext, _textView)),
169-
_editorFormatMapService,
170-
_textView);
171123

172-
return newAdornment;
173-
}
124+
// Get the active selection to make sure the rename text is selected in the same way
125+
var originalSpan = _renameService.ActiveSession.TriggerSpan;
126+
var selectionSpan = _textView.Selection.SelectedSpans.First();
127+
128+
var start = selectionSpan.IsEmpty
129+
? 0
130+
: selectionSpan.Start - originalSpan.Start; // The length from the identifier to the start of selection
131+
132+
var length = selectionSpan.IsEmpty
133+
? originalSpan.Length
134+
: selectionSpan.Length;
135+
136+
var identifierSelection = new TextSpan(start, length);
137+
138+
var adornment = new RenameFlyout(
139+
(RenameFlyoutViewModel)s_createdViewModels.GetValue(
140+
_renameService.ActiveSession,
141+
session => new RenameFlyoutViewModel(session,
142+
identifierSelection,
143+
registerOleComponent: true,
144+
_globalOptionService,
145+
_threadingContext,
146+
_listenerProvider,
147+
_smartRenameSessionFactory)),
148+
_textView,
149+
_asyncQuickInfoBroker,
150+
_threadingContext,
151+
_listenerProvider);
152+
153+
return adornment;
174154
}
175155

176156
private static bool ViewIncludesBufferFromWorkspace(IWpfTextView textView, Workspace workspace)
@@ -184,13 +164,5 @@ private static bool ViewIncludesBufferFromWorkspace(IWpfTextView textView, Works
184164
Workspace.TryGetWorkspace(textContainer, out var workspace);
185165
return workspace;
186166
}
187-
188-
private static void LogAdornmentChoice(bool useInlineAdornment)
189-
{
190-
TelemetryLogging.Log(FunctionId.InlineRenameAdornmentChoice, KeyValueLogMessage.Create(m =>
191-
{
192-
m[nameof(useInlineAdornment)] = useInlineAdornment;
193-
}));
194-
}
195167
}
196168
}

src/EditorFeatures/Core.Wpf/InlineRename/UI/InlineRenameAdornmentProvider.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
2727
internal class InlineRenameAdornmentProvider : IWpfTextViewConnectionListener
2828
{
2929
private readonly InlineRenameService _renameService;
30-
private readonly IEditorFormatMapService _editorFormatMapService;
3130
private readonly IInlineRenameColorUpdater? _dashboardColorUpdater;
3231
private readonly IWpfThemeService? _themeingService;
3332
private readonly IGlobalOptionService _globalOptionService;
@@ -56,7 +55,6 @@ internal class InlineRenameAdornmentProvider : IWpfTextViewConnectionListener
5655
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
5756
public InlineRenameAdornmentProvider(
5857
InlineRenameService renameService,
59-
IEditorFormatMapService editorFormatMapService,
6058
[Import(AllowDefault = true)] IInlineRenameColorUpdater? dashboardColorUpdater,
6159
[Import(AllowDefault = true)] IWpfThemeService? themeingService,
6260
IGlobalOptionService globalOptionService,
@@ -68,7 +66,6 @@ public InlineRenameAdornmentProvider(
6866
#pragma warning restore CS0618
6967
{
7068
_renameService = renameService;
71-
_editorFormatMapService = editorFormatMapService;
7269
_dashboardColorUpdater = dashboardColorUpdater;
7370
_themeingService = themeingService;
7471
_globalOptionService = globalOptionService;
@@ -85,7 +82,8 @@ public InlineRenameAdornmentProvider(
8582
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
8683
{
8784
// Create it for the view if we don't already have one
88-
textView.GetOrCreateAutoClosingProperty(v => new InlineRenameAdornmentManager(_renameService, _editorFormatMapService, _dashboardColorUpdater, v, _globalOptionService, _themeingService, _asyncQuickInfoBroker, _listenerProvider, _threadingContext, _smartRenameSessionFactory));
85+
textView.GetOrCreateAutoClosingProperty(v => new InlineRenameAdornmentManager(
86+
_renameService, _dashboardColorUpdater, v, _globalOptionService, _themeingService, _asyncQuickInfoBroker, _listenerProvider, _threadingContext, _smartRenameSessionFactory));
8987
}
9088

9189
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)

src/EditorFeatures/Core/InlineRename/AbstractInlineRenameUndoManager.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ protected class ActiveSpanState
2929
}
3030

3131
protected readonly InlineRenameService InlineRenameService;
32-
private readonly IGlobalOptionService _globalOptionService;
3332
protected readonly Dictionary<ITextBuffer, TBufferState> UndoManagers = [];
3433
protected readonly Stack<ActiveSpanState> UndoStack = new Stack<ActiveSpanState>();
3534
protected readonly Stack<ActiveSpanState> RedoStack = new Stack<ActiveSpanState>();
@@ -39,10 +38,9 @@ protected class ActiveSpanState
3938

4039
private InlineRenameSession _trackedSession;
4140

42-
public AbstractInlineRenameUndoManager(InlineRenameService inlineRenameService, IGlobalOptionService globalOptionService)
41+
public AbstractInlineRenameUndoManager(InlineRenameService inlineRenameService)
4342
{
4443
this.InlineRenameService = inlineRenameService;
45-
_globalOptionService = globalOptionService;
4644

4745
InlineRenameService.ActiveSessionChanged += InlineRenameService_ActiveSessionChanged;
4846
}
@@ -54,17 +52,6 @@ private void InlineRenameService_ActiveSessionChanged(object sender, InlineRenam
5452
_trackedSession.ReplacementTextChanged -= InlineRenameSession_ReplacementTextChanged;
5553
}
5654

57-
if (!_globalOptionService.GetOption(InlineRenameUIOptionsStorage.UseInlineAdornment))
58-
{
59-
// If the user is typing directly into the editor as the only way to change
60-
// the replacement text then we don't need to respond to text changes. The
61-
// listener on the textview that calls UpdateCurrentState will handle
62-
// this correctly. This option cannot change when we are currently in a session, so
63-
// only hook up as needed
64-
_trackedSession = null;
65-
return;
66-
}
67-
6855
_trackedSession = InlineRenameService.ActiveSession;
6956

7057
if (_trackedSession is not null)

src/EditorFeatures/Core/InlineRename/CommandHandlers/AbstractRenameCommandHandler.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ internal abstract partial class AbstractRenameCommandHandler(
2626
{
2727
public string DisplayName => EditorFeaturesResources.Rename;
2828

29-
protected abstract bool AdornmentShouldReceiveKeyboardNavigation(ITextView textView);
30-
3129
protected abstract void SetFocusToTextView(ITextView textView);
3230

3331
protected abstract void SetFocusToAdornment(ITextView textView);
3432

35-
protected abstract void SetAdornmentFocusToPreviousElement(ITextView textView);
36-
37-
protected abstract void SetAdornmentFocusToNextElement(ITextView textView);
38-
3933
private CommandState GetCommandState(Func<CommandState> nextHandler)
4034
{
4135
if (renameService.ActiveSession != null)

src/EditorFeatures/Core/InlineRename/CommandHandlers/AbstractRenameCommandHandler_TabHandler.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)