Skip to content

Expand extractSymbol ranges - #42770

Merged
Jesse Trinity (jessetrinity) merged 6 commits into
microsoft:masterfrom
jessetrinity:expandExtractRanges
Feb 17, 2021
Merged

Jesse Trinity (jessetrinity) merged 6 commits into
microsoft:masterfrom
jessetrinity:expandExtractRanges

Conversation

@jessetrinity

@jessetrinity Jesse Trinity (jessetrinity) commented Feb 11, 2021 •

Copy link
Copy Markdown
Contributor

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.

@jessetrinity

Copy link
Copy Markdown
Contributor Author
@amcasey

Copy link
Copy Markdown
Member

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

@amcasey Andrew Casey (amcasey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly questions.

Comment thread src/services/refactors/extractSymbol.ts Resolved
Comment thread src/services/refactors/extractSymbol.ts Resolved
Comment thread src/services/refactors/extractSymbol.ts Resolved
Comment thread src/services/refactors/extractSymbol.ts Resolved
@jessetrinity

Jesse Trinity (jessetrinity) commented Feb 16, 2021 •

Copy link
Copy Markdown
Contributor Author

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".

@amcasey Andrew Casey (amcasey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@jessetrinity
Jesse Trinity (jessetrinity) merged commit d640313 into microsoft:master Feb 17, 2021
@microsoft 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

3 participants