Skip to content

Conversation

@jessetrinity
Copy link
Contributor

@jessetrinity jessetrinity commented Feb 11, 2021

Fixes #41469

When a refactor is invoked through a keyboard command we search a bit harder for the extract symbol refactor by treating the selected span as though it covers the tokens containing the start and end tokens.

That is, selecting

const foo = ba[|r + b|]az;

will be equivalent to selecting

const foo = [|bar + baz|];

for the purposes of offering the refactor to extract bar + baz.

I also separated out the unit tests into individual tests so we can tell them apart on failure.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 11, 2021
@jessetrinity jessetrinity changed the title Expand extract ranges Expand extract symbol ranges Feb 11, 2021
@jessetrinity jessetrinity changed the title Expand extract symbol ranges Expand extractSymbol ranges Feb 11, 2021
@jessetrinity
Copy link
Contributor Author

cc @mjbvz

@amcasey
Copy link
Member

amcasey commented Feb 16, 2021

Does this resolve #41469 or is it just related? That issue seems to be about doing this for all refactorings.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly questions.

@jessetrinity
Copy link
Contributor Author

jessetrinity commented Feb 16, 2021

I expect that #41469 only relates to extractSymbol. Other refactorings generally only use the start of the span to search for an applicable refactor, so the "explicit cursor request" from #38378 should suffice. extractSymbol relies more on the start and end nodes both being in the right places so it needed special logic to "try harder".

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jessetrinity jessetrinity merged commit d640313 into microsoft:master Feb 17, 2021
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

Not seeing refactorings try to intelligently expand based on the current selection

3 participants