Skip to content

Commit

Permalink
be consistent with default behaviour when closing }
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
predragnikolic committed Oct 30, 2023
1 parent d49244e commit 9e7f40a
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.js | source.jsx | source.ts | source.tsx | text.html.ngx | text.html.svelte | text.html.vue" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\{", "match_all": true }
]},
{"keys": ["{"], "command": "chain",
"args": {
Expand All @@ -22,8 +23,26 @@
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.js | source.jsx | source.ts | source.tsx | text.html.ngx | text.html.svelte | text.html.vue" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "\\\\$", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\$", "match_all": true },
]},
// move cursor after '}'
// if '}' is in front of cursor
{"keys": ["}"], "command": "chain",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": true}},
{"command": "convert_to_template_string"},
]
},
"context": [
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.js | source.jsx | source.ts | source.tsx | text.html.ngx | text.html.svelte | text.html.vue" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\$\\{.?+", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }
]},
// insert '}'
// if '}' is not in front of cursor
{"keys": ["}"], "command": "chain",
"args": {
"commands": [
Expand All @@ -35,5 +54,7 @@
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.js | source.jsx | source.ts | source.tsx | text.html.ngx | text.html.svelte | text.html.vue" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\$\\{.?+", "match_all": true },
{ "key": "following_text", "operator": "not_regex_contains", "operand": "^\\}", "match_all": true }
]},
]
]

0 comments on commit 9e7f40a

Please sign in to comment.