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

Show "You cannot rename this element" *before* letting the user write a new name #26536

Closed
CherryDT opened this issue May 12, 2017 · 3 comments
Closed
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s)

Comments

@CherryDT
Copy link

Version 1.13.0-insider
Commit c615b43
Date 2017-05-09T06:13:02.691Z
Shell 1.6.6
Renderer 56.0.2924.87
Node 7.4.0

When pressing F2 to rename a variable, VSCode always lets you enter the new name, only afterwards it appears to check whether the rename is possible and if not, it shows "You cannot rename this element".

It would be better to check this first, before even prompting for a new name, to avoid frustration that what was just written has been lost and has to be written again after using Ctrl+D or similar.

@jrieken
Copy link
Member

jrieken commented May 12, 2017

dupe of #7340

@jrieken jrieken closed this as completed May 12, 2017
@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label May 12, 2017
@CherryDT
Copy link
Author

Wow I didn't find that issue in the search ;)

From what I now understand, this is hard to implement because there are various implementations for different languages which all have their own handling and would need to get support for this... But I wonder whether there would be a way to "test" this before, e.g. telling the provider to rename, either to the same thing as before, or (in case this is caught and prevented) to a temporary name, and then not applying the change (or invisibly reverting it), in order to detect whether rename is possible. But I guess this would be a can of worms in case the rename is expensive or in case there are only so-many things allowed to rename that thing to and your temporary value is not one of them...

@jrieken
Copy link
Member

jrieken commented May 15, 2017

But I guess this would be a can of worms in case the rename is expensive or in case there...

Yeah, you'll be on thin ice. When we designed the rename API and flow we ended up with the common denominator which is a plain rename. Having said that most providers are smarter and can validate a range before attempting to rename a symbol, esp TypeScript and C# should be fit for this

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants