Skip to content

Commit f0bc60d

Browse files
committed
Fix settings completions with spaces before comma
Set a new meta scope for the region after the value up to and including the following comma. This way we can easily target the whole thing with our completions. Fixes #147.
1 parent a757851 commit f0bc60d

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Package/Sublime JSON/Sublime JSON.sublime-syntax

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,20 @@ contexts:
401401
scope: invalid.illegal.expected-colon.json
402402

403403
in-mapping-expect-comma:
404-
- include: comments
405-
- match: ','
406-
scope: punctuation.separator.mapping.pair.json
407-
pop: true
408-
- match: (?=})
409-
pop: true
410-
- match: \s*(?=")
411-
scope: invalid.illegal.expected-comma.inside-mapping.json
412-
pop: true
413-
- match: \S
414-
scope: invalid.illegal.expected-comma.inside-mapping.json
404+
- match: ''
405+
set:
406+
- meta_scope: meta.expect-comma.sublime
407+
- include: comments
408+
- match: ','
409+
scope: punctuation.separator.mapping.pair.json
410+
pop: true
411+
- match: (?=})
412+
pop: true
413+
- match: \s*(?=")
414+
scope: invalid.illegal.expected-comma.inside-mapping.json
415+
pop: true
416+
- match: \S
417+
scope: invalid.illegal.expected-comma.inside-mapping.json
415418

416419
mapping-value-meta:
417420
- clear_scopes: 1

Package/Sublime Text Settings/syntax_test_settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ s
1111
// <- meta.mapping.json punctuation.section.mapping.begin.json
1212
// ^ meta.mapping.json comment.line.double-slash.js punctuation.definition.comment.json
1313

14-
"key": "value",
14+
"key": "value" ,
1515
// ^^^^^^^^^^^^^^^^^ meta.mapping - meta.mapping meta.mapping
1616
// ^^^^^ meta.mapping.key.json string.quoted.double.json - meta.mapping.json
1717
// ^ punctuation.definition.string.begin.json
1818
// ^ punctuation.definition.string.end.json
1919
// ^ punctuation.separator.mapping.key-value.json
2020
// ^^^^^^^ meta.setting-value.sublime-settings meta.mapping.value.json string.quoted.double.json
21-
// ^ punctuation.separator.mapping.pair.json
21+
// ^ punctuation.separator.mapping.pair.json
2222
// ^ - meta.expect-value.sublime-settings
2323
// ^ meta.expect-value.sublime-settings
24+
// ^^^ meta.expect-comma.sublime
25+
// ^ - meta.expect-comma.sublime
2426

2527
"another_key": 123,
2628
// ^ - entity.name.other.key.sublime-settings

plugins_/settings/region_math.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
# match top-level keys only
32
KEY_SCOPE = "entity.name.other.key.sublime-settings"
43
KEY_COMPLETIONS_SCOPE = (
54
"meta.settings-mapping.sublime-settings - comment - meta.setting-value.sublime-settings"
65
" | " + KEY_SCOPE
76
)
87
VALUE_SCOPE = (
9-
"meta.expect-value | meta.setting-value.sublime-settings"
10-
" | punctuation.separator.mapping.pair.json"
8+
"meta.expect-value.sublime-settings | meta.setting-value.sublime-settings"
9+
" | meta.expect-comma.sublime"
1110
)
1211

1312

0 commit comments

Comments
 (0)