You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow language extensions to override editor.wordSeparators #33701
There's a pretty common request from PowerShell extension users to enable double-click selection of variable names like $myVar including the initial dollar sign character. After some research it seems that the only way to control this double-click selection behavior is by having the user change their editor.wordSeparators setting to remove the $ which is included by default.
Is there any way that a language extension can override this setting (or behavior) for a specific language aside from editing the user's settings file to add this setting? If not, is it possible to programmatically add or edit a language-specific config section (like [powershell]) in the user's config?
Thanks!
Reacted by Øyvind Kallstad, Martin Gill, Cody W. Geisler, Jarrod Nix, Anuradha Dissanayake, Thomas Boby, Yu Zhang, Talv, JeffreyCA, Peter Flannery and 12 more
Following up on David Wilson (@daviwil)'s question: Without looking for an implementation, is there any mechanism currently available to change the word separation characters for particular languages or extensions (i.e. as an extension developer)?
Yes, and in our case I think an API for the extension to hook in or set this setting (or one related to it) is desired — some way to specify that word separators for our particular language do not include $. That kind of setting doesn't really make sense to me on a per-user basis — everyone using PowerShell (in our case) will generally want the same word definition and not need to set it themselves.
Just found this is problematic for code completion for 'words' which begin with $ as well. The code completion (24|7) is not triggered until the next character (eg. the f of $f) is typed, simple insertion (with the CompletionItem.label) results in double $$ as a result. The $ is not highlighted in the suggestions either.
Setting the wordSeparators (as the user) still doesn't trigger code completion until after the first non-$ character. I'm assuming this would be the case for any other character not present (removed) from the wordSeparators list, which IMO is contrary to the user's intent in that case.
Removing a character from that list should make it valid as a 'word' character. Thus, for the $ case, a$b should be added to the auto complete list (of words in the file) but it isn't.
Is it possible to define editor.wordSeparators on a per language basis? (as asked by the original poster?)
Currently, when editing PHP file, if I double click on variables, selectors, values, etc., with hyphens in them, I end up selecting on part of it. E.g., Double-clicking review in jgm-review-widget will only select review. I would expect it to select jgm-review-widget in its entirety.
Activity
daviwil commentedon Sep 1, 2017
Related issues:
jrrdnx commentedon Feb 21, 2018
I would like this as well. For me:
rjmholt commentedon Jun 17, 2018
Following up on David Wilson (@daviwil)'s question: Without looking for an implementation, is there any mechanism currently available to change the word separation characters for particular languages or extensions (i.e. as an extension developer)?
TylerLeonhardt commentedon Jun 18, 2018
Looks like it's easily configurable:
https://stackoverflow.com/questions/31632351/visual-studio-code-customizing-word-separators
shanesmithdev commentedon Jun 18, 2018
@tylerl0706 - that was mentioned in the original post that started this discussion.
The request is to extend that, so that it can be defined on a per-language (or per-filetype) basis, rather than globally.
rjmholt commentedon Jun 19, 2018
Yes, and in our case I think an API for the extension to hook in or set this setting (or one related to it) is desired — some way to specify that word separators for our particular language do not include
$. That kind of setting doesn't really make sense to me on a per-user basis — everyone using PowerShell (in our case) will generally want the same word definition and not need to set it themselves.HookyQR commentedon Feb 15, 2019
Just found this is problematic for code completion for 'words' which begin with
$as well. The code completion (24|7) is not triggered until the next character (eg. thefof$f) is typed, simple insertion (with theCompletionItem.label) results in double$$as a result. The$is not highlighted in the suggestions either.Setting the wordSeparators (as the user) still doesn't trigger code completion until after the first non-
$character. I'm assuming this would be the case for any other character not present (removed) from the wordSeparators list, which IMO is contrary to the user's intent in that case.Removing a character from that list should make it valid as a 'word' character. Thus, for the
$case,a$bshould be added to the auto complete list (of words in the file) but it isn't.Version 1.31.0-insider (2019-02-04)
TylerLeonhardt commentedon Mar 5, 2019
Add this to your settings to get this only for PowerShell!:
{ "[powershell]": { "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?" } }I think this means we can close this issue? 😊
HookyQR commentedon Mar 5, 2019
Doesn't solve my problem of symbols beginning with characters considered to be
wordSeparatorsby default.TylerLeonhardt commentedon Mar 5, 2019
Hooky (@HookyQR) I believe this might be a PowerShell extension issue. Can you test something for me?
Open this file:
and modify line 45 from:
to
Note the additional
\$?.HookyQR commentedon Mar 18, 2019
I'm saying, I'm creating a new extension, I don't use powershell, or the extension. The problem is in the VS Code mainline ... somewhere. 🤷♂️
inspiredearth commentedon Apr 21, 2020
Where did this issue get to?
Is it possible to define
editor.wordSeparatorson a per language basis? (as asked by the original poster?)Currently, when editing PHP file, if I double click on variables, selectors, values, etc., with hyphens in them, I end up selecting on part of it. E.g., Double-clicking
reviewinjgm-review-widgetwill only selectreview. I would expect it to selectjgm-review-widgetin its entirety.inspiredearth commentedon Apr 21, 2020
I seem to have answered my own question. Applying the following User Setting, I was able to modify
editor.wordSeparatorsfor just PHP:TylerLeonhardt commentedon Apr 21, 2020
Yeah I think this issue can be closed.