From e5e083f0544a4da98f57b828c0e0633d36b4f860 Mon Sep 17 00:00:00 2001 From: Kyriel Abad Date: Wed, 2 Oct 2024 15:59:45 +0800 Subject: [PATCH] Revert "Fix faulty regex for syntax highlighter (#1723)" This reverts commit 883ffe766d7df25a6e44dd9f8a3ba208ae7cfee5. --- src/__tests__/mode.ts | 11 +---------- src/editors/ace/modes/source.ts | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/__tests__/mode.ts b/src/__tests__/mode.ts index 12f318aff..9f792e21a 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; \n5 + num |2;' + const code = 'const num = 3; \nnum++; \nnum--; \nnum += 1;' setSession(Chapter.SOURCE_1, defaultVariant, defaultExternal, code) @@ -91,15 +91,6 @@ 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 2b402101d..c507e581e 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}|--+|\+\++|\^|(==|!=)[^=]|[$%&*+\-~\/^]=+|(?