-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
TS Template added by @mjbvz
TypeScript Version: 3.8.2
Search Terms
- expand selection
- selectionRange
Issue Type: Feature Request (maybe Bug)
Reproduce
Given these code examples (javascript or javascriptreact), run Expand Selection a few times:
const func = () => {
|<-- put caret here
};
// or...
const func = () => {|<-- put caret here
};
// or...
function func(params) {
|<-- put caret here
}Actual
Expand Selection skips the body of the function and goes straight to selecting the whole function.
Expected
Should be able to select the function body when using Expand Selection, regardless of where I started inside the function.
In WebStorm it works as expected:
I find myself updating the body of an arrow function dozens of times a day, usually to inline the return expression as an implicit return.
Of course there are extensions and ESLint rules that can help with that, but Expand Selection should respect the function body block regardless.
Update: More examples
const func = () => {
// some comment
const one = 1;
};- Placing caret to the left of
// some:- Expand Selection just once will select the whole arrow function (from
()to the closing}).
- Expand Selection just once will select the whole arrow function (from
- Placing caret to the left of
const:- Expand Selection actually works as expected, after 4 times, only the body of the arrow function is selected (although it doesn't select it including the
{}, but that's not so bad).
- Expand Selection actually works as expected, after 4 times, only the body of the arrow function is selected (although it doesn't select it including the
Here's the example where I first encountered this issue:
const func = () => {
return someFunc();
};- Select and Cut
someFunc();(caret will be to the right ofreturnat this point) - Expand Selection > results in selecting the whole function (from
()to the closing}) - If I first move the caret to the left of
return, then Expand Selection works as expected.
System Details
VS Code version: Code - Insiders 1.40.0-insider (c58aaab, 2019-10-22T05:25:41.549Z)
VS Code version: Code 1.42.1 (c47d83b293181d9be64f27ff093689e8e7aed054, 2020-02-11T14:44:27.652Z)
OS version: Darwin x64 18.7.0

