Skip to content

Commit 212ffc7

Browse files
committed
Mousemap: Add support for context key
Was added in build 4149. Closes #388
1 parent 54384c0 commit 212ffc7

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

Package/Sublime Text Mousemap/Completions/Main Keys (in-string).sublime-completions

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"details": "Command name",
1717
"kind": ["keyword", "k", "main"],
1818
},
19+
{
20+
"trigger": "context",
21+
"details": "Context restrictions",
22+
"kind": ["keyword", "k", "main"],
23+
},
1924
{
2025
"trigger": "args",
2126
"details": "Command arguments",

Package/Sublime Text Mousemap/Completions/Main Keys.sublime-completions

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"details": "Command name",
2020
"kind": ["keyword", "k", "main"],
2121
},
22+
{
23+
"trigger": "context",
24+
"contents": "\"context\": [\n\t$0\n],",
25+
"details": "Context restrictions",
26+
"kind": ["keyword", "k", "main"],
27+
},
2228
{
2329
"trigger": "press_command",
2430
"contents": "\"press_command\": \"$1\",$0",

Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ contexts:
6060
2: keyword.other.main.sublime-mousemap
6161
3: punctuation.definition.string.end.json
6262
set: [expect-command-name-value, expect-colon]
63+
- match: (")(context)(")
64+
scope: meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json
65+
captures:
66+
1: punctuation.definition.string.begin.json
67+
2: keyword.other.main.sublime-keymap
68+
3: punctuation.definition.string.end.json
69+
set: [in-mapping-expect-comma, expect-context-sequence-value, expect-colon]
6370
- match: (")((?:press_)?args)(")
6471
scope: meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json
6572
captures:
@@ -197,6 +204,10 @@ contexts:
197204
in-mapping-expect-comma:
198205
- include: Sublime JSON.sublime-syntax#in-mapping-expect-comma
199206

207+
expect-context-sequence-value:
208+
# This means we have keymap suffixes in the scopes, but I'm lazy enough not to care
209+
- include: Sublime Text Keymap.sublime-syntax#expect-context-sequence-value
210+
200211
mapping-value-meta:
201212
- clear_scopes: 1 # remove `meta.mapping.json`
202213
- meta_scope: meta.mapping.value.json

Package/Sublime Text Mousemap/syntax_test_mousemap.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@
101101
// ^^ - invalid
102102
// ^ punctuation.separator.sequence.json
103103

104+
{
105+
"context": [
106+
// ^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json
107+
// ^ punctuation.definition.string.begin.json
108+
// ^^^^^^^ keyword.other.main.sublime-keymap
109+
// ^ punctuation.definition.string.end.json
110+
// ^ punctuation.separator.mapping.key-value.json
111+
// ^ meta.keybinding-context-collection.sublime-keymap punctuation.section.sequence.begin.json
112+
{ "key": "group_has_multiselect", "operator": "equal", "operand": "" },
113+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.keybinding-context-collection.sublime-keymap meta.keybinding-context.sublime-keymap meta.mapping
114+
// ^ meta.mapping.json punctuation.section.mapping.begin.json
115+
// ^^^^^ meta.mapping.key.json meta.context-key.sublime-keymap string.quoted.double.json
116+
// ^ punctuation.definition.string.begin.json
117+
// ^^^ support.function.context.sublime-keymap
118+
// ^ punctuation.definition.string.end.json
119+
// ^ meta.mapping.json punctuation.separator.mapping.key-value.json
120+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.context.key-value.key.other.sublime-keymap string.quoted.double.json
121+
// ^ punctuation.definition.string.begin.json
122+
// ^^^^^^^^^^^^^^^^^^^^^ storage.type.context.key-value.sublime-keymap
123+
// ^ punctuation.definition.string.end.json
124+
// (we assume the rest will be matched correctly and is separately tested in the keymap syntax)
125+
],
126+
}
104127

105128
{
106129

0 commit comments

Comments
 (0)