-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Expand selection functionality issues #4795
Comments
I was too optimistic planning this for April. The current implementation is based of token/scope information in TM grammars. The issue is that each grammar does it different, like |
@rozzzly, @TobiaszCudnik Since I am not as familiar with the optimal solution can you guys help out with 'how it should work?'. I guess, selector word, line?, bracket/paran-block? ... |
I like the way it's implemented in https://atom.io/packages/expand-region or at Jetbrain's products like Webstorm |
Inner-camelCase expansion would be cool.
Would it be best to have people just list out a bunch of examples, using something like the markup I just used to show the behaviour desired? Then, from those. distil the logic in regards to he AST? There's a lot of edgecases I would think, that might be easier |
@jrieken The simplest solution I see is to combine the AST and word separators. Case-sensitive boundaries could be implemented as a word separator as well. In IntelliJ it works also for CTRL+Left/Right jumps, when active. I really count for this feature, as it saves a lot of time when moving code around. |
Thanks all for the input. Note that we do not have access to the AST or any other form of syntax tree. Even token information isn't working well enough. So it's unfortunately entirely word based |
I think improving smartSelect is a great plan. I agree with the suggestions for making smartSelect even more useful. Might I suggest that #11458 is solving for a different problem? I get the feeling that mixing its requirements in with smartSelect could further bog down smartSelect. In my mind, smartSelect is about being able to quickly select something nearby the cursor. Whereas #11458 is about quickly selecting everything within a bounding context. If smartSelect were enhanced to achieve this type of eventual selection, it would still have the downside of repeated keystrokes to achieve the "select stuff inside here" functionality. So they feel similar because the end result is "intelligent selection" but I suspect in-the-end they would function better as separate features. Thanks for listening. :) |
The value of optimal Expand Select and Shrink Select commands is high in my opinion. I used to use ReSharper in Visual Studio and their implementation was about perfect. When I use this command, I'm usually looking to copy, replace, or delete certain code.
...it should snap first to the function name...
...and next to the function name with the parentheses...
...and next to the entire function block...
If my selection is inside the function, however, I would expect the progression to look something like...
Note that my suggestion progression has rather small steps. For instance, after selecting the expression |
Just wanted to add that it would be great for this to work with python code, where code blocks aren't delineated by brackets or parentheses, but tabs (currently, once it you expand the selection beyond the current block in a python file, all of the code is selected). I'll second that I'd like to see it work as in the Jetbrains products. In PyCharm it works great with both python and javascript files. |
|
Is it possible to get an update on this? |
I found this functionality really limited in VS Code, it is not as fine grained as I'd wish. |
For anyone who has landed here and - just like me - wasn't aware of a way to solve this for now, I've found this wonderful extension that can do this and much more in regards to selection expansion (works like a charm for HTML as well). If you're not sure about what keys to bind this to, here's how I set it: EDIT: I should note that the above commands are used by VSCode in tl;dr:
¹ Usually at |
I confirm this Expand Selection functionality is eagerly awaited. We can always rely on extension to fix it but a better built-in support for such a thing is the least a user can expect from a code editor. Expand a selection in a string such as I hope to see all the feature users above describe to come up. |
There are several issues I've encountered as well (this is JS):
|
It's quite shocking how impoverished the expand selection feature is in a major code editor! It's dramatically inadequate compared to Webstorm. The VS Code team should hire someone from Jetbrains. These issues have been running for 2 years. |
@Maxhodges some support shipped last update: https://code.visualstudio.com/updates/v1_31#_smart-selections Looks like there's more to come too, see the various related issues |
yes, that's what I just tested. It was a miserable failure. I think the authors of this feature don't share the same vision. The way Webstorm has implemented this feature it makes it an extremely useful productivity enhancement; in vscode it's a 2-year-running exercise in frustration and disappointment. |
@Maxhodges Can you please be more specific on what is lacking? This is still a work in progress, so specific feedback would probably be helpful in shaping how it ends up. This could especially be the case if, as you say, the vision differs. |
The behavior in the various JetBrains IDEs is excellent in my opinion. As an example, here's the behavior for each selection increment ( return moment(value[type], 'YYYY-M[]M-DD');
return moment(value[type], 'YYYY-[MM]-DD');
return moment(value[type], '[YYYY-MM-DD]');
return moment(value[type], ['YYYY-MM-DD']);
return moment([value[type], 'YYYY-MM-DD']);
return moment[(value[type], 'YYYY-MM-DD')];
return [moment(value[type], 'YYYY-MM-DD')];
[return moment(value[type], 'YYYY-MM-DD');] Like this I can step through parts I might want to change easily - and even select logical blocks (e.g. dash-separated groups) inside strings easily. |
@ThiefMaster Thanks! Something like that is not at odds with their vision and would be easily implemented with the new API. There was apparently an issue according to #64004 where the token information was not sufficient for the default provider to work like that for strings (or function calls), but the API can be used per language so it can be smarter. The issue is simply that it has not yet been implemented for that language. |
While it might be possible for the default provider to be improved further, it would be best to rely on language-specific selection which will probably be adopted after the API is finalized during the current iteration. Language-specific issues should then have their own Issues so that the maintainers of their respective language extensions can address them. |
It also doesn't work with script tags or style tags in html. It just treats it as an HTML element and selects thewhole tag, rather than the closest block. |
Are you looking for contributors on this issue? Also, will the resolution deal specifically with multi-cursor support of the feature? I noted that 40516 was closed as a dupe of this issue, but I don't see anything regarding multi-cursor noted here. |
@anied The API (which was delayed) does support multiple cursors. It takes a |
@KamasamaK - Certainly, thanks for taking the time to look into this. Here is my VSCode version info: I just checked for updates and found none. Consider the following code selection: const username = new MDCTextField(document.querySelector('.username'));
const password = new MDCTextField(document.querySelector('.password'));
new MDCRipple(document.querySelector('.cancel'));
new MDCRipple(document.querySelector('.next')); Now I can select the So, as far as I understand it, there remains here a bug in which expanding selection loses multi-cursor context, but perhaps I am misunderstanding or trying to execute this incorrectly. Thanks for taking the time to review this. |
Closing this as we have finalised the extension API for VS Code 1.33 (planned to ship this week). Remaining work is tracked here: https://github.com/Microsoft/vscode/labels/smart-select. Please file new issues for more feedback. Thanks & Happy Coding! |
Steps to Reproduce:
scope.vm.renderSettings = {};
renderSettings
editor.action.smartSelect.grow
Expected behavior:
renderSettings
part would be selectedCurrent behavior:
the whole left part of statement selected with tabs.
Also would be nice to see the fix with smart grow, when
editor.action.smartSelect.grow
executed in series.The text was updated successfully, but these errors were encountered: