diff --git a/src/__tests__/mode.ts b/src/__tests__/mode.ts index 9f792e21a..12f318aff 100644 --- a/src/__tests__/mode.ts +++ b/src/__tests__/mode.ts @@ -79,7 +79,7 @@ test('constants are not correctly loaded', () => { }) test('operator syntax type error', () => { - const code = 'const num = 3; \nnum++; \nnum--; \nnum += 1;' + const code = 'const num = 3; \nnum++; \nnum--; \nnum += 1; \n5 + num |2;' setSession(Chapter.SOURCE_1, defaultVariant, defaultExternal, code) @@ -91,6 +91,15 @@ test('operator syntax type error', () => { const token3 = session.getTokenAt(3, 5) expect(expectedBool(token3, CATEGORY.forbidden)).toBe(true) + + const token4 = session.getTokenAt(4, 1) + expect(expectedBool(token4, CATEGORY.number)).toBe(true) + + const token5 = session.getTokenAt(4, 9) + expect(expectedBool(token5, CATEGORY.forbidden)).toBe(true) + + const token6 = session.getTokenAt(4, 10) + expect(expectedBool(token6, CATEGORY.number)).toBe(true) }) test('forbidden keywords', () => { diff --git a/src/editors/ace/modes/source.ts b/src/editors/ace/modes/source.ts index c507e581e..2b402101d 100644 --- a/src/editors/ace/modes/source.ts +++ b/src/editors/ace/modes/source.ts @@ -113,9 +113,9 @@ export function HighlightRulesSelector( const VariantForbiddenRegexSelector = () => { if (variant === Variant.TYPED) { // Removes the part of the regex that highlights singular |, since Typed variant uses union types - return /\.{3}|--+|\+\++|\^|(==|!=)[^=]|[$%&*+\-~\/^]=+|[^&]*&[^&]/ + return /\.{3}|--+|\+\++|\^|(==|!=)[^=]|[$%&*+\-~\/^]=+|(?