From d5851e995363e6f637a5f35cafe3ddaf8934705a Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 14 Oct 2026 02:52:07 +0000 Subject: feat(plugin): highlight exception keywords with C++ scopes Reuse C++ try, catch and throw scopes for exception keywords, with ENDTRY sharing the TRY scope. Add an example and verify keyword boundaries, case sensitivity, comments and strings with TextMate tokenization. Co-Authored-By: Claude Fable 5.1 --- plugin/test/highlighting.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'plugin/test/highlighting.test.js') diff --git a/plugin/test/highlighting.test.js b/plugin/test/highlighting.test.js index 24751bf..0f677a3 100644 --- a/plugin/test/highlighting.test.js +++ b/plugin/test/highlighting.test.js @@ -53,6 +53,22 @@ test('both assignment characters share the C++ assignment scope', () => { assert.ok(!scopesAt('X - 1', '-').includes('keyword.operator.assignment.cpp')); }); +test('exception keywords reuse C++ scopes and ignore non-keyword occurrences', () => { + for (const [word, scope] of [ + ['TRY', 'keyword.control.try.cpp'], + ['CATCH', 'keyword.control.catch.cpp'], + ['THROW', 'keyword.control.throw.cpp'], + ['ENDTRY', 'keyword.control.try.cpp'] + ]) { + assert.ok(scopesAt(word, word).includes(scope)); + assert.ok(scopesAt(`// ${word}`, word).some(s => s.startsWith('comment.'))); + assert.ok(scopesAt(`OUTPUT "${word}"`, word).some(s => s.startsWith('string.'))); + for (const text of [word.toLowerCase(), `${word}Value`, `My${word}`, `${word}_1`]) { + assert.ok(!scopesAt(text, text).some(s => s.startsWith('keyword.')), text); + } + } +}); + test('comments, strings, lowercase and keyword prefixes cannot become keywords', () => { assert.ok(scopesAt('// IF [(', 'IF').some(s => s.startsWith('comment.'))); assert.ok(scopesAt('OUTPUT "IF // ["', 'IF').some(s => s.startsWith('string.'))); -- cgit v1.3.1-4-g156e