Skip to content
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

Connect inline rename UI to editor smart rename session #70420

Merged
merged 40 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
71c4553
Update all the essential packages
Cosifne Oct 9, 2023
7da4fef
Fix the package warnings
Cosifne Oct 9, 2023
42b5591
Add Editor.Internal
Cosifne Oct 9, 2023
463bf68
Move to wpf layer
Cosifne Oct 9, 2023
3d94c3f
Link smart rename session to the view model
Cosifne Oct 9, 2023
65e61d3
Add control
Cosifne Oct 12, 2023
52ea0c2
Hook up view model
Cosifne Oct 12, 2023
fd3d2be
Hook task
Cosifne Oct 12, 2023
a9475e4
Fix build errors
Cosifne Oct 12, 2023
a03834b
Rename
Cosifne Oct 12, 2023
4c66ea0
Use TestVM to tune the UI
Cosifne Oct 12, 2023
835dd6b
Extract to common resources
Cosifne Oct 12, 2023
b0c07b5
Bind to view model
Cosifne Oct 13, 2023
11c26ab
Link view model
Cosifne Oct 16, 2023
6b183aa
Only update the selection when isSelect is true
Cosifne Oct 16, 2023
4a534ff
Move logic to code behind
Cosifne Oct 16, 2023
5391c9d
Sync the life time with view model
Cosifne Oct 16, 2023
2263da0
Add mock in test
Cosifne Oct 16, 2023
d894a4a
Correct bind to inline model
Cosifne Oct 17, 2023
74b7121
Tune the UI
Cosifne Oct 17, 2023
6c020fc
Remove the UI from legacy rename control
Cosifne Oct 17, 2023
a9a9784
Add scrolling function
Cosifne Oct 17, 2023
845a542
Add resources
Cosifne Oct 17, 2023
12adddf
Rename
Cosifne Oct 17, 2023
a391e9b
Suppress warning in prod code
Cosifne Oct 17, 2023
7b10d42
Suppress warning in test code
Cosifne Oct 17, 2023
e990fd4
Pass threading context to control
Cosifne Oct 18, 2023
68fce28
Address PR feedback
Cosifne Oct 19, 2023
9f9b1ae
Plase cursor to the end
Cosifne Oct 19, 2023
350b42e
When navigate the suggestions, circle the list
Cosifne Oct 19, 2023
2a7320d
Use file scope namespace
Cosifne Oct 19, 2023
2837fdb
Add comment
Cosifne Oct 19, 2023
21c9797
Add comments
Cosifne Oct 19, 2023
a23dfdb
Change version reference
Cosifne Oct 19, 2023
7c3c064
Add more assert message to help debug
Cosifne Oct 19, 2023
b09f0e1
Merge remote-tracking branch 'upstream/release/dev17.9' into dev/shec…
Cosifne Oct 20, 2023
394f56a
Use another event
Cosifne Oct 23, 2023
2a20482
Skip the broken test
Cosifne Oct 23, 2023
c618e5c
Reset TestState.vb
Cosifne Oct 23, 2023
a5a4627
Add CompleteAsyncOperation
Cosifne Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.149-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.6.0</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>17.7.188</VisualStudioEditorPackagesVersion>
<VisualStudioEditorPackagesVersion>17.9.1-preview</VisualStudioEditorPackagesVersion>
<ILAsmPackageVersion>6.0.0-rtm.21518.12</ILAsmPackageVersion>
<ILDAsmPackageVersion>6.0.0-rtm.21518.12</ILDAsmPackageVersion>
<MicrosoftVisualStudioLanguageServerClientPackagesVersion>17.7.4-preview</MicrosoftVisualStudioLanguageServerClientPackagesVersion>
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>17.8.9-preview</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.7.37349</MicrosoftVisualStudioShellPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.8.36711</MicrosoftVisualStudioShellPackagesVersion>
<!-- The version of MSBuild that we reference for things depending on MSBuildWorkspace -->
<RefOnlyMicrosoftBuildPackagesVersion>16.10.0</RefOnlyMicrosoftBuildPackagesVersion>
<!-- The version of MSBuild that matches the version of MSBuild.StructuredLogger for apps using MSBuild as a regular API -->
Expand All @@ -41,7 +41,7 @@
the generators we build would load on the command line but not load in IDEs. -->
<SourceGeneratorMicrosoftCodeAnalysisVersion>4.1.0</SourceGeneratorMicrosoftCodeAnalysisVersion>
<MicrosoftILVerificationVersion>7.0.0-alpha.1.22060.1</MicrosoftILVerificationVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.7.30</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.8.14</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftTestPlatformVersion>17.4.1</MicrosoftTestPlatformVersion>
</PropertyGroup>
<!--
Expand Down Expand Up @@ -83,7 +83,7 @@
<MicrosoftBuildTasksCoreVersion>$(MicrosoftBuildPackagesVersion)</MicrosoftBuildTasksCoreVersion>
<MicrosoftBuildUtilitiesCoreVersion>$(MicrosoftBuildPackagesVersion)</MicrosoftBuildUtilitiesCoreVersion>
<NuGetVisualStudioContractsVersion>6.0.0-preview.0.15</NuGetVisualStudioContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.5.14-alpha</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.9.3-alpha</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftAspNetCoreRazorExternalAccessRoslynWorkspaceVersion>8.0.0-preview.23465.2</MicrosoftAspNetCoreRazorExternalAccessRoslynWorkspaceVersion>
<!--
Since the Microsoft.CodeAnalysis.Analyzers package is a public dependency of our NuGet
Expand Down Expand Up @@ -118,7 +118,7 @@
<MicrosoftExtensionsLoggingConsoleVersion>6.0.0</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.8.27812-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioInteropVersion>17.7.37349</MicrosoftInternalVisualStudioInteropVersion>
<MicrosoftInternalVisualStudioInteropVersion>17.8.36711</MicrosoftInternalVisualStudioInteropVersion>
<MicrosoftInternalVisualStudioShellFrameworkVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftInternalVisualStudioShellFrameworkVersion>
<MicrosoftIORedistVersion>6.0.0</MicrosoftIORedistVersion>
<MicrosoftIORedistVersion>6.0.0</MicrosoftIORedistVersion>
Expand All @@ -136,7 +136,7 @@
<MicrosoftNuGetBuildTasksVersion>0.1.0</MicrosoftNuGetBuildTasksVersion>
<MicrosoftPortableTargetsVersion>0.1.2-dev</MicrosoftPortableTargetsVersion>
<MicrosoftServiceHubClientVersion>4.2.1017</MicrosoftServiceHubClientVersion>
<MicrosoftServiceHubFrameworkVersion>4.3.50</MicrosoftServiceHubFrameworkVersion>
<MicrosoftServiceHubFrameworkVersion>4.4.16</MicrosoftServiceHubFrameworkVersion>
<MicrosoftSourceLinkToolsVersion>1.1.1-beta-21566-01</MicrosoftSourceLinkToolsVersion>
<MicrosoftTeamFoundationServerClientVersion>16.170.0</MicrosoftTeamFoundationServerClientVersion>
<MicrosoftTestPlatformTranslationLayerVersion>$(MicrosoftTestPlatformVersion)</MicrosoftTestPlatformTranslationLayerVersion>
Expand All @@ -145,26 +145,26 @@
<MicrosoftVisualStudioCacheVersion>17.3.26-alpha</MicrosoftVisualStudioCacheVersion>
<MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>15.8.27812-alpha</MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>
<MicrosoftVisualStudioCodeAnalysisSdkUIVersion>15.8.27812-alpha</MicrosoftVisualStudioCodeAnalysisSdkUIVersion>
<MicrosoftVisualStudioComponentModelHostVersion>17.7.187</MicrosoftVisualStudioComponentModelHostVersion>
<MicrosoftVisualStudioCompositionVersion>17.7.18</MicrosoftVisualStudioCompositionVersion>
<MicrosoftVisualStudioComponentModelHostVersion>17.8.181</MicrosoftVisualStudioComponentModelHostVersion>
<MicrosoftVisualStudioCompositionVersion>17.7.26</MicrosoftVisualStudioCompositionVersion>
<MicrosoftVisualStudioCoreUtilityVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioCoreUtilityVersion>
<MicrosoftVisualStudioDebuggerUIInterfacesVersion>17.6.0-beta.23252.1</MicrosoftVisualStudioDebuggerUIInterfacesVersion>
<MicrosoftVisualStudioDebuggerContractsVersion>17.6.0-beta.23252.1</MicrosoftVisualStudioDebuggerContractsVersion>
<MicrosoftVisualStudioDebuggerEngineimplementationVersion>17.8.1072001-preview</MicrosoftVisualStudioDebuggerEngineimplementationVersion>
<MicrosoftVisualStudioDebuggerMetadataimplementationVersion>17.8.1072001-preview</MicrosoftVisualStudioDebuggerMetadataimplementationVersion>
<MicrosoftVisualStudioDesignerInterfacesVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioDesignerInterfacesVersion>
<MicrosoftVisualStudioDiagnosticsMeasurementVersion>17.0.0-preview-1-30928-1112</MicrosoftVisualStudioDiagnosticsMeasurementVersion>
<MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>
<MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>17.8.36726</MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>
<MicrosoftVisualStudioSDKEmbedInteropTypesVersion>15.0.36</MicrosoftVisualStudioSDKEmbedInteropTypesVersion>
<MicrosoftVisualStudioEditorVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioEditorVersion>
<MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion>$(MicrosoftVisualStudioExtensibilityTestingVersion)</MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion>
<MicrosoftVisualStudioExtensibilityTestingXunitVersion>$(MicrosoftVisualStudioExtensibilityTestingVersion)</MicrosoftVisualStudioExtensibilityTestingXunitVersion>
<MicrosoftVisualStudioGraphModelVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioGraphModelVersion>
<MicrosoftVisualStudioImageCatalogVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioImageCatalogVersion>
<MicrosoftVisualStudioImagingVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioImagingVersion>
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>17.8.36726</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioInternalMicroBuildNpmPackVersion>2.0.93</MicrosoftVisualStudioInternalMicroBuildNpmPackVersion>
<MicrosoftVisualStudioInteropVersion>17.7.37355</MicrosoftVisualStudioInteropVersion>
<MicrosoftVisualStudioInteropVersion>17.8.36711</MicrosoftVisualStudioInteropVersion>
<MicrosoftVisualStudioLanguageVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioLanguageVersion>
<MicrosoftVisualStudioLanguageCallHierarchyVersion>15.8.27812-alpha</MicrosoftVisualStudioLanguageCallHierarchyVersion>
<MicrosoftVisualStudioLanguageIntellisenseVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioLanguageIntellisenseVersion>
Expand All @@ -187,7 +187,7 @@
<MicrosoftVisualStudioRemoteControlVersion>16.3.52</MicrosoftVisualStudioRemoteControlVersion>
<MicrosoftVisualStudioSDKAnalyzersVersion>16.10.10</MicrosoftVisualStudioSDKAnalyzersVersion>
<MicrosoftVisualStudioSearchVersion>17.5.0-preview-2-33111-081</MicrosoftVisualStudioSearchVersion>
<MicrosoftVisualStudioSetupConfigurationInteropVersion>3.7.2175</MicrosoftVisualStudioSetupConfigurationInteropVersion>
<MicrosoftVisualStudioSetupConfigurationInteropVersion>3.8.2094</MicrosoftVisualStudioSetupConfigurationInteropVersion>
<MicrosoftVisualStudioShell150Version>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShell150Version>
<MicrosoftVisualStudioShellFrameworkVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioShellDesignVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShellDesignVersion>
Expand All @@ -202,7 +202,7 @@
<MicrosoftVisualStudioThreadingVersion>$(MicrosoftVisualStudioThreadingPackagesVersion)</MicrosoftVisualStudioThreadingVersion>
<MicrosoftVisualStudioUtilitiesVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioUtilitiesInternalVersion>16.3.53</MicrosoftVisualStudioUtilitiesInternalVersion>
<MicrosoftVisualStudioValidationVersion>17.6.11</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioValidationVersion>17.8.8</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioInteractiveWindowVersion>4.0.0</MicrosoftVisualStudioInteractiveWindowVersion>
<MicrosoftVisualStudioVsInteractiveWindowVersion>4.0.0</MicrosoftVisualStudioVsInteractiveWindowVersion>
<MicrosoftVisualStudioWinFormsInterfacesVersion>17.0.0-previews-4-31709-430</MicrosoftVisualStudioWinFormsInterfacesVersion>
Expand Down Expand Up @@ -301,7 +301,7 @@
create a test insertion in Visual Studio to validate.
-->
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
<StreamJsonRpcVersion>2.16.36</StreamJsonRpcVersion>
<StreamJsonRpcVersion>2.17.8</StreamJsonRpcVersion>
<!--
When updating the S.C.I or S.R.M version please let the MSBuild team know in advance so they
can update to the same version. Version changes require a VS test insertion for validation.
Expand Down
3 changes: 3 additions & 0 deletions src/EditorFeatures/Core.Wpf/EditorFeaturesWpfResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,7 @@
<data name="Enter_to_rename_shift_enter_to_preview" xml:space="preserve">
<value>Enter to rename, Shift+Enter to preview</value>
</data>
<data name="Generating_suggestions" xml:space="preserve">
<value>Generating suggestions...</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
<Border
BorderThickness="1"
x:Name="Outline">
<StackPanel Orientation="Vertical" Margin="5" >
<Grid Margin="0 0 0 10">
<StackPanel x:Name="MainPanel" Orientation="Vertical" Margin="5" >
<Grid x:Name="IdentifierAndExpandButtonGrid" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="22" />
</Grid.ColumnDefinitions>


<TextBox
Grid.Column="0"
x:Name="IdentifierTextBox"
Text="{Binding IdentifierText, UpdateSourceTrigger=PropertyChanged}"
GotFocus="IdentifierTextBox_GotFocus"
HorizontalAlignment="Stretch" />
HorizontalAlignment="Stretch"
PreviewKeyDown="IdentifierTextBox_KeyDown"/>

<!-- Expand/Collapse button and glyph -->
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.InlineRename.UI.SmartRename;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.PlatformUI;
Expand All @@ -26,12 +28,14 @@ internal partial class RenameFlyout : InlineRenameAdornment
private readonly IWpfTextView _textView;
private readonly IAsyncQuickInfoBroker _asyncQuickInfoBroker;
private readonly IAsynchronousOperationListener _listener;
private readonly IThreadingContext _threadingContext;

public RenameFlyout(
RenameFlyoutViewModel viewModel,
IWpfTextView textView,
IWpfThemeService? themeService,
IAsyncQuickInfoBroker asyncQuickInfoBroker,
IThreadingContext threadingContext,
IAsynchronousOperationListenerProvider listenerProvider)
{
DataContext = _viewModel = viewModel;
Expand All @@ -41,6 +45,7 @@ public RenameFlyout(
_textView.ViewportHeightChanged += TextView_ViewPortChanged;
_textView.ViewportWidthChanged += TextView_ViewPortChanged;
_listener = listenerProvider.GetListener(FeatureAttribute.InlineRenameFlyout);
_threadingContext = threadingContext;

// On load focus the first tab target
Loaded += (s, e) =>
Expand All @@ -55,6 +60,14 @@ public RenameFlyout(

InitializeComponent();

// If smart rename is available, insert the control after the identifier text box.
if (viewModel.SmartRenameViewModel is not null)
{
var smartRenameControl = new SmartRenameControl(viewModel.SmartRenameViewModel);
var index = MainPanel.Children.IndexOf(IdentifierAndExpandButtonGrid);
MainPanel.Children.Insert(index + 1, smartRenameControl);
}

if (themeService is not null)
{
Outline.BorderBrush = new SolidColorBrush(themeService.GetThemeColor(EnvironmentColors.AccentBorderColorKey));
Expand Down Expand Up @@ -222,5 +235,27 @@ private void IdentifierTextBox_SelectionChanged(object sender, RoutedEventArgs e
var startPoint = _viewModel.InitialTrackingSpan.GetStartPoint(buffer.CurrentSnapshot);
_textView.SetSelection(new SnapshotSpan(startPoint + start, length));
}

private void IdentifierTextBox_KeyDown(object sender, KeyEventArgs e)
{
// When smart rename is available, allow the user choose the suggestions using the up/down keys.
_threadingContext.ThrowIfNotOnUIThread();
var smartRenameViewModel = _viewModel.SmartRenameViewModel;
if (smartRenameViewModel is not null)
{
var currentIdentifier = IdentifierTextBox.Text;
if (e.Key is Key.Down or Key.Up)
{
var newIdentifier = smartRenameViewModel.ScrollSuggestions(currentIdentifier, down: e.Key == Key.Down);
if (newIdentifier is not null)
{
_viewModel.IdentifierText = newIdentifier;
// Place the cursor at the end of the input text box.
IdentifierTextBox.Select(newIdentifier.Length, 0);
e.Handled = true;
}
}
}
}
}
}
Loading
Loading