Repository navigation
Add opt-in user preference for prefix and suffix text on renames - #29314
Ben Lichtman (uniqueiniquity) merged 21 commits into
Conversation
| !!args.findInStrings, | ||
| !!args.findInComments | ||
| !!args.findInComments, | ||
| this.getHostPreferences().usePrefixAndSuffixTextForRename || false |
There was a problem hiding this comment.
this.getHostPreferences().usePrefixAndSuffixTextForRename || false [](start = 16, length = 66)
Since there may be multiple preferences affecting rename behavior (e.g. #28677), would it make more sense to pass in the entire preferences object (e.g. as in getEditsForFileRename)?
There was a problem hiding this comment.
Switched to passing entire preferences object.
However I only passed it as deep as this call; any deeper would require an API change, so I didn't want to do that unless absolutely necessary.
|
Do you have a plan for when and how to remove this code? It's pretty ugly and I think it will only be needed for another 6 months or so. (Maybe more, depending on how long we ship new versions of TS to old versions of VS). |
|
Nathan Shively-Sanders (@sandersn) Don't we have to keep this until the newest version of VS without the opt-in is deprecated? I'm guessing that will be longer than 6 months. |
|
Andrew Casey (@amcasey) Per our in-person discussion, we'll want to ship new TS servers to VS versions that shipped at least 2 years ago. (Plus we haven't done the work to make VS work with the new API anyway.) |
Nathan Shively-Sanders (sandersn)
left a comment
There was a problem hiding this comment.
I take it you figured out how to make this work without changing getTypeAtLocation at all? If so, then sounds good. :)
|
Nathan Shively-Sanders (@sandersn) yep, it was a red herring. |
|
Andrew Casey (@amcasey) Can you take another look? I attempted to consolidate conditions like we discussed. |
Andrew Casey (amcasey)
left a comment
There was a problem hiding this comment.
Still a few questions but generally LGTM.
|
Does this being a config setting mean it'll count as fixing #29238? |
|
Wesley Wigham (@weswigham) It means editors will have the option of exposing that as a setting but, arguably, it won't be fixed until they do. |
|
Since we've had a number of asks for #29238, we should try to make sure it's exposed as a setting in VS and VSCode, at least. |
|
Wesley Wigham (@weswigham) we can certainly plan to make it optional in VS. AFAIK Matt Bierner (@mjbvz) has already made it the default in VS Code |
|
Andrew Casey (@amcasey) Correct on your first comment, in no case do we want to rename the identifier |
commented
Apr 6, 2019
|
Ben Lichtman (@uniqueiniquity) - I just tried this new feature for the first time (thank you so much for building it!) and I was surprised that renaming a property of a named, destructured export wouldn't rename the symbol when it's imported in another file. Is this expected? I'll file a separate issue if not expected. Here's the repro:
type ReadonlyAndNotUndefined<T> = { readonly [P in keyof T]: string; }
export const {
APP_NAME,
MONGODB_CONNECTION_URI,
SENDGRID_API_KEY,
NOTIFICATION_URL_BASE,
NOTIFICATION_FROM_EMAIL,
} = process.env as ReadonlyAndNotUndefined<typeof process.env>;
import { NOTIFICATION_URL_BASE, SENDGRID_API_KEY, NOTIFICATION_FROM_EMAIL } from './env';
Expected: name is also changed in Note that if you export individual variables (not via destructuring export) the rename works fine, e.g. |
Fixes #28679
This PR adds a user preference which, if not set, returns the rename behavior on shorthand properties and import/export specifiers to its state in 3.1.