Skip to content

Commit

Permalink
Improve "word" experience in vscode.
Browse files Browse the repository at this point in the history
The model (form language-configuration.json) accepts '-' as long as it
is surrounded by '\w'.

However, the editor still uses '-' as word boundary. This combination
sounds counter-intuitive, but works okish with highlighting: the
model is used to find the initial word, and the editor then finds
"whole" words by using the separators. This means that `--foo-bar` finds
other `foo-bar`s (and, more importantly, `foo-bar` also finds
`--foo-bar`). However, it also means that `foo-bar-gee` will now also be
highlighted for the `foo-bar` part.

A correct solution will use the LSP, which can provide a good list of
the identifiers that are relevant. (Initially maybe just all
identifiers that would match).
  • Loading branch information
floitsch committed Aug 10, 2023
1 parent 3e7d662 commit b83bd2d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion vscode/language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
["\"", "\""],
["'", "'"]
],
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s\\$]+)",
"wordPattern": "(-?\\d*\\.\\d\\w*)|(\\w(-?\\w)*)",
"indentationRules": {
"increaseIndentPattern": "[\\:]([\\s]*\\|(\\s*[\\w-]+)+\\s*\\|)?$",
"decreaseIndentPattern": "^[\\s]*else[\\:]$"
Expand Down
1 change: 0 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"contributes": {
"configurationDefaults": {
"[toit]": {
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?",
"editor.indentSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false
Expand Down

0 comments on commit b83bd2d

Please sign in to comment.