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

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Oct 17, 2023

Thanks to @AmadeusW which added an internal preview API to suggested names based on copilot results.
This PR connects this to our inline rename UI
How it looks:
SmartRenameInC#

User could double-click & navigate using the keyboard to select the suggested names.

A few points:

  1. This would only be available in inline rename UI now. For our legacy UI, when the suggested identifier in ViewModel changed, this line would stop the change from propagating to the text editor, because traditionally we only expect text change from the editor in legacy UI. I don't want to regress this behavior so we need a way to tell if the feature is ON in the editor feature layer (Currently it is only targeting net472, and no good way to check if from option service). I have talked to Amadeus this is on his note.
  2. It needs to consume 17.9 APIs, if the integration test fails I will create main-vs-deps branch for it.
  3. Would be best if could be covered by an integration test, but given it's quite difficult to enable this I feel it's not possible. The real logic is mostly handled by the editor, we are just providing a thin UI wrapper around it, so I guess it might be fine now?

@Cosifne Cosifne requested review from a team as code owners October 17, 2023 23:32
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 17, 2023
@Cosifne
Copy link
Member Author

Cosifne commented Oct 19, 2023

i have mixed feelings abouthe spinner (since it's pretty distracting). Could this just be cycling:

Generating suggestions .
Generating suggestions ..
Generating suggestions ...

?

As @AmadeusW proposed they want to have this checked to asap to get the backend tested.
I do have some draft UI idea & impl, will create following PR

@Cosifne
Copy link
Member Author

Cosifne commented Oct 19, 2023

Synced with the infra folks so it's agreed now we use release/dev17.9 as our old vs-deps branch.
Waiting for the branch model/policy to update now..

_renameService.ActiveSession,
session => new RenameFlyoutViewModel(session,
identifierSelection,
registerOleComponent: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know what the registerOleComponent bit is about?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just warp all the argument here, guess Andrew @ryzngard would know this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registering for Ole fails in unit tests (I'd have to dig deeper to remember why) so we have this for testing purposes. Production code should always be true.

@@ -0,0 +1,91 @@
<UserControl x:Class="Microsoft.CodeAnalysis.InlineRename.UI.SmartRename.SmartRenameControl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryzngard for xaml review.

<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Width="238" HorizontalAlignment="Left"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly concerned about hardcoded values like 238. where did that number come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this from the editor side impl, tag @AmadeusW here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd try it without tbh. It should fill the space of the panel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the width limitation, it will try to put everything in the same line
image

{
if (e.ClickCount == 1)
{
var identifierName = ((FrameworkElement)sender).Tag.ToString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we know that the sender is a framework eleemnt, or that the tag contains the info we need?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By wpf definition https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement.tag?view=windowsdesktop-7.0
Then tag is directly binded to the display string in xaml
image

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this is safe in WPF as long as this method is used for mouse events.

foreach (var name in _smartRenameSession.SuggestedNames)
{
SuggestedNames.Add(name);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think an observable collection has a way to say "i'm about to make a bunch of changes" so it doesn't notify on each change.

@CyrusNajmabadi
Copy link
Member

Ok. This looks good to me. However, i'd like @jasonmalinowski @sharwell to have a pass, since they're experts in hooking things into the UI properly :)

@@ -396,7 +396,7 @@ End Class
End Using
End Function

<WpfFact>
<WpfFact(Skip:="https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1906990")>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed after updating the VS editor package to 17.9. (Only fails in our CI, Spanish VM)
#70471

Test is testing the behavior for both our code & editor side impl of IAsyncCompletionBroker.
So, if this is regressed, it's already in VS, since editor team owns the insertion of the dll.
I have talked to Gen and we can temp skip this test and let editor folks to investigate this

@Cosifne Cosifne merged commit 65b05fa into dotnet:release/dev17.9 Oct 24, 2023
22 of 27 checks passed
@Cosifne
Copy link
Member Author

Cosifne commented Oct 24, 2023

Will monitor the health of Integration test from Dart lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants