Skip to content

Commit 623d7cd

Browse files
committed
Fix module vs variant highlighting in some cases
See tests
1 parent 8458527 commit 623d7cd

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

ReScript.sublime-syntax

+4-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ contexts:
137137
constructor:
138138
- match: '\b[A-Z][0-9a-zA-Z_]*\b'
139139
# won't mark and highlight this for now. This often shares the same
140-
# highlighting as entity.name.namespace (our module). We don't want
140+
# highlighting as entity.name.namespace our module). We don't want
141141
# variant and modules confused
142142
# scope: entity.name.union
143143
scope: variable.function variable.other
@@ -235,6 +235,9 @@ contexts:
235235
- match: \)
236236
scope: punctuation.section.parens.end
237237
pop: true
238+
- match: \{
239+
scope: punctuation.section.braces.begin
240+
push: moduleInner
238241
- include: moduleAccessEndsWithModule
239242
- include: main
240243

syntax_test.res

+13-9
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,13 @@ include Belt.Map.Make()
159159
Foo.Some(Bar)
160160
// <- source.res entity.name.namespace
161161
// ^ source.res
162+
// ^^^ variable.function variable.other
162163
// ^ source.res
163164
Foo.Some(Bar())
164165
// ^ source.res
166+
// ^^^ variable.function variable.other
165167
Foo.make(Bar())
168+
// ^^^ variable.function variable.other
166169
module Bla = Belt.Map.Make(Bar({type t let a:b = "cc"}))
167170
// ^ source.res entity.name.namespace
168171
// ^ keyword.operator.assignment
@@ -183,13 +186,13 @@ module SetOfIntPairs = MakeSet((IntPair), Bar);
183186
// ^ source.res entity.name.namespace
184187
module SetOfIntPairs = MakeSet(IntPair({type t = Bar}))
185188
// ^ source.res entity.name.namespace
186-
// ^^^ entity.name.namespace
189+
// ^^^ variable.function variable.other
187190
module Foo = (Bar: Baz) => (Bar: Baz) => {let a = Bar};
188191
// ^ source.res entity.name.namespace
189192
// ^ source.res entity.name.namespace
190193
// ^ source.res entity.name.namespace
191194
// ^ source.res entity.name.namespace
192-
// ^ source.res
195+
// ^^^ variable.function variable.other
193196
module Foo = (Bar: Baz) => (Bar: Baz) => List;
194197
// ^ source.res entity.name.namespace
195198

@@ -220,7 +223,7 @@ module School = {
220223
// ^ source.res entity.name.namespace
221224
{
222225
type a = Bar
223-
// ^ source.res
226+
// ^^^ variable.function variable.other
224227
let a = ["1"]
225228
}
226229
) => {
@@ -243,24 +246,25 @@ module School = {
243246
module Nested = (Foo: Bar, {type a = Bar let a = 1 } ) => {
244247
// ^ source.res entity.name.namespace
245248
// ^ source.res entity.name.namespace
246-
// ^ source.res
249+
// ^^^ variable.function variable.other
247250
module NestMore = Bla
248251
module NestMore: Foo = Bla
249252
module NestMore: {type t = Bar} = Bla
250253
// ^ source.res punctuation.section.braces.begin
251-
// ^ source.res
254+
// ^^^ variable.function variable.other
252255
// ^ source.res punctuation.section.braces.end
253256
// ^ source.res entity.name.namespace
254257
module NestMore: {type t = Bar} = {
255-
// ^ source.res
258+
// ^^^ variable.function variable.other
256259
type t = Variant
257-
// ^ source.res
260+
// ^^^^^^^ variable.function variable.other
258261
let a = ["hello"]
259262
}
260263
module NestMore = (Foo: {type t = Variant}) => Bla
264+
// ^^^^^^^ variable.function variable.other
261265
module NestMore: Bla = (Foo: {}) => Bla
262266
module NestMore: {type t = Bar let a: b = "cc" module Foo = {}} = (Foo: {}) => Bla
263-
// ^ source.res
267+
// ^^^ variable.function variable.other
264268
// ^ source.res entity.name.namespace
265269
module type NestMore = {}
266270
module NestMore = () => Bla.Qux
@@ -272,7 +276,7 @@ let p: School.School2.profession = School.getProfession(School.Foo)
272276
// ^ source.res entity.name.namespace
273277
// ^ source.res entity.name.namespace
274278
// ^ source.res entity.name.namespace
275-
// ^ source.res
279+
// ^^^ variable.function variable.other
276280

277281
let getAudience = (~excited) => excited ? "world!" : "world"
278282

0 commit comments

Comments
 (0)