-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Provide the range of the symbol to be renamed during rename refactors #32685
Comments
When you say "send a rename" do you mean send an It isn't clear from the documentation what the If that's not what you're seeing, then it sounds like a bug. |
Sorry, I should've included more info. Yes, I mean exactly what you said. Here's a sample... Given the file: import "dart:async" as b;
main() async {
await new b.Future.delayed(const Duration(seconds: 1));
} If I send a rename on the word The problem with this is that the rename box would be populate with the entire line, when it should only contain As a workaround, I may reject renames where
|
Note: I'm sending an offset of 0 and a length of 6 for the rename because Code is expanding to the nearest word (this is part of the wonky behave they're fixing). Probably as part of the changes I will just sent the offset and always a length of 0 and that should work? |
Actually, as a better workaround (that won't fail if the lengths just match up by fluke) is for me to read the content from the document at the offset/length provided and see if it matches |
@scheglov Is the selection of the whole import directive intentional? |
I can see some logic to it if it might be considered weird if the returned range doesn't include the offset you sent; but it ties my hands here. VS Code really doesn't want to allow extensions to supply the text directly and although I could search inside the provided range for the text from |
No, using the range of the whole import directive it not intentional. Not 100% sure what to do when there is no import prefix, probably use |
I can handle -1/0 but I think it might be nicer to provide a valid range to avoid the chance of someone not handling it and then having the editor crash on an invalid value. I'd personally pick the empty range before the semicolon (since that's where the edit would be). |
…r names. R=brianwilkerson@google.com Bug: #32685 Change-Id: I40b7f9c679b04725db19dad661e3a88a4a982f1c Reviewed-on: https://dart-review.googlesource.com/48682 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Currently if I send a rename for an import like:
The range I get back is the whole line. The VS Code API is being improved to allow us to handle more renames, but they won't allow us to provide the text to pre-populate the rename box directly (effectively the
oldName
property), only a range for where it appears in the document (I've tried and tried to change their minds with no luck).Is it possible to have this added (in the case where the name doesn't exist - for example if the above didn't include an alias) can return an empty range (I'd put it before the semi-colon, but it doesn't really matter if it's empty so the box is populated blank)?
@bwilkerson
The text was updated successfully, but these errors were encountered: