Skip to content

Fix modifier order for class member completions #48066

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

Merged
merged 2 commits into from
Mar 1, 2022
Merged

Conversation

gabritto
Copy link
Member

Fixes #46568 (third item).

This PR makes it so that, when the user has already typed in some modifiers (e.g. abstract, override), we replace those already present modifiers, and then insert the class member signature (which will contain the already present modifiers). Before, we were not replacing the already present modifier, and instead just adding the new modifiers after those, causing the modifier order to be wrong in some cases (e.g. if the user had already typed abstract but we needed to insert private along with the signature, we'd get abstract private foo, but the correct order is private abstract foo).

I also removed replacementSpans of length 0 from some fourslash tests, as those are useless.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 28, 2022
@gabritto
Copy link
Member Author

@andrewbranch on the useless replacement spans, I'm not sure what was happening before that led me to add them, but looking at the code now, it looks like as of #42013 we don't check the actual replacement span if the expected replacement span has 0 length. Why did we do this? I also wonder if it shouldn't be the opposite, as in, if the actual replacement span has length 0, we don't need to specify a expected replacement span.

@andrewbranch
Copy link
Member

andrewbranch commented Mar 1, 2022

On the replacement spans, I probably intended the opposite, but in hindsight I think replacement spans are such an important piece of info that they should probably always be checked to be an exact match, even if it wasn’t provided in the expected.

@andrewbranch
Copy link
Member

Although if that requires updating a bunch of tests, maybe not worth enforcing that now.

@gabritto gabritto merged commit e64f04b into main Mar 1, 2022
@gabritto gabritto deleted the gabritto/issue46568pt3 branch March 1, 2022 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method snippet follow-up
3 participants