-
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
Implement textDocument/prepareRename for better rename experience #70724
Conversation
d257e93
to
c828c34
Compare
src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs
Outdated
Show resolved
Hide resolved
|
||
return new DefaultBehaviorPrepareRename | ||
{ | ||
DefaultBehavior = true, |
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.
curious what 'default' means in this context.
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.
Default means default rename behavior. Prepare allows you to specify a special range, but we don't use that.
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.
thanks! what is an example of a 'special range'? (just for my understanding).
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.
The range to rename - see the docs on the return value here https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_prepareRename
src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs
Show resolved
Hide resolved
Looked into piggy backing off this to add support to Razor, and FYI this will break rename in VS if the handler lights up there (ie, when LSP is turned on): https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1914930 |
@davidwengier it sounds like if I merge this it will break rename in Razor, is that correct? Or will it continue working because Razor doesn't call Roslyn's prepare rename? |
It's cool, you can merge. We don't advertise prepare rename support, so they won't call us, and we won't call you. In fact, if we do want to support we can workaround the client issue in Razor, by translating your response into a range response, so we're not blocked either way. |
Resolves dotnet/vscode-csharp#6643
Why
Two benefits of implementing prepare rename
Before this change - rename on invalid identifier
After this change - rename on invalid identifier