diff --git a/grammars/Babel Language.json b/grammars/Babel Language.json index 15204ab..ce6d8b7 100644 --- a/grammars/Babel Language.json +++ b/grammars/Babel Language.json @@ -1273,6 +1273,12 @@ "1": { "name": "keyword.operator.$1.js" } } }, + { + "match": "\\s*+(\\?\\?)", + "captures": { + "1": { "name": "keyword.operator.nullcoalesce.js" } + } + }, { "match": "\\s*+(!(?!=)|&&|\\|\\|)", "captures": { diff --git a/spec/fixtures/grammar/issues.js b/spec/fixtures/grammar/issues.js index eab0c2b..73fffc6 100644 --- a/spec/fixtures/grammar/issues.js +++ b/spec/fixtures/grammar/issues.js @@ -1,5 +1,93 @@ // SYNTAX TEST "source.js.jsx" +// Issue #495 +const undefinedValue = response.settings?.undefinedValue ?? 'some other default'; // result: 'some other default' +// <- storage.type.js + // <- storage.type.js +//^^^ storage.type.js +// ^^^^^^^^^^^^^^ variable.other.readwrite.js +// ^ keyword.operator.assignment.js +// ^^^^^^^^ variable.other.object.js +// ^ keyword.operator.accessor.js +// ^^^^^^^^ ^^^^^^^^^^^^^^ meta.property.object.js +// ^^^^^^^^ ^^^^^^^^^^^^^^ variable.other.property.js +// ^^ keyword.operator.existential.js +// ^^ keyword.operator.nullcoalesce.js +// ^^^^^ ^^^^^ ^^^^^^^^ string.quoted.single.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^ punctuation.terminator.statement.js +// ^^ ^^^^^^^ ^^^^^ ^^^^^ ^^^^^^^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js +const nullValue = response.settings?.nullValue ?? 'some other default'; // result: 'some other default' +// <- storage.type.js + // <- storage.type.js +//^^^ storage.type.js +// ^^^^^^^^^ variable.other.readwrite.js +// ^ keyword.operator.assignment.js +// ^^^^^^^^ variable.other.object.js +// ^ keyword.operator.accessor.js +// ^^^^^^^^ ^^^^^^^^^ meta.property.object.js +// ^^^^^^^^ ^^^^^^^^^ variable.other.property.js +// ^^ keyword.operator.existential.js +// ^^ keyword.operator.nullcoalesce.js +// ^^^^^ ^^^^^ ^^^^^^^^ string.quoted.single.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^ punctuation.terminator.statement.js +// ^^ ^^^^^^^ ^^^^^ ^^^^^ ^^^^^^^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js +const headerText = response.settings?.headerText ?? 'Hello, world!'; // result: '' +// <- storage.type.js + // <- storage.type.js +//^^^ storage.type.js +// ^^^^^^^^^^ variable.other.readwrite.js +// ^ keyword.operator.assignment.js +// ^^^^^^^^ variable.other.object.js +// ^ keyword.operator.accessor.js +// ^^^^^^^^ ^^^^^^^^^^ meta.property.object.js +// ^^^^^^^^ ^^^^^^^^^^ variable.other.property.js +// ^^ keyword.operator.existential.js +// ^^ keyword.operator.nullcoalesce.js +// ^^^^^^^ ^^^^^^^ string.quoted.single.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^ punctuation.terminator.statement.js +// ^^ ^^^^^^^ ^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js +const animationDuration = response.settings?.animationDuration ?? 300; // result: 0 +// <- storage.type.js + // <- storage.type.js +//^^^ storage.type.js +// ^^^^^^^^^^^^^^^^^ variable.other.readwrite.js +// ^ keyword.operator.assignment.js +// ^^^^^^^^ variable.other.object.js +// ^ keyword.operator.accessor.js +// ^^^^^^^^ ^^^^^^^^^^^^^^^^^ meta.property.object.js +// ^^^^^^^^ ^^^^^^^^^^^^^^^^^ variable.other.property.js +// ^^ keyword.operator.existential.js +// ^^ keyword.operator.nullcoalesce.js +// ^^^ constant.numeric.js +// ^ punctuation.terminator.statement.js +// ^^ ^^^^^^^ ^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js +const showSplashScreen = response.settings?.showSplashScreen ?? true; // result: false +// <- storage.type.js + // <- storage.type.js +//^^^ storage.type.js +// ^^^^^^^^^^^^^^^^ variable.other.readwrite.js +// ^ keyword.operator.assignment.js +// ^^^^^^^^ variable.other.object.js +// ^ keyword.operator.accessor.js +// ^^^^^^^^ ^^^^^^^^^^^^^^^^ meta.property.object.js +// ^^^^^^^^ ^^^^^^^^^^^^^^^^ variable.other.property.js +// ^^ keyword.operator.existential.js +// ^^ keyword.operator.nullcoalesce.js +// ^^^^ constant.language.boolean.true.js +// ^ punctuation.terminator.statement.js +// ^^ ^^^^^^^ ^^^^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js + // Issue #480 const thing :THING =() => {} // <- storage.type.js