From e52266d8ce8823866b2dad3e04ffc78438e08397 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 05:58:39 +0000 Subject: feat(plugin): add keyword Tab indentation and selection formatting Co-Authored-By: Claude Fable 5.1 --- plugin/src/lexical.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plugin/src/lexical.js (limited to 'plugin/src/lexical.js') diff --git a/plugin/src/lexical.js b/plugin/src/lexical.js new file mode 100644 index 0000000..3fc856a --- /dev/null +++ b/plugin/src/lexical.js @@ -0,0 +1,33 @@ +'use strict'; + +// Preserve UTF-16 offsets and newlines, masking CIE quotes and // comments. +// Unlike C++, CIE has no escapes or multiline literals. +function codeOnly(text) { + let quote = null; + let comment = false; + const result = []; + for (let i = 0; i < text.length; i++) { + const char = text[i]; + if (char === '\n' || char === '\r') { + quote = null; + comment = false; + result.push(char); + } else if (comment) { + result.push(' '); + } else if (quote) { + if (char === quote) quote = null; + result.push(' '); + } else if (char === '"' || char === "'") { + quote = char; + result.push(' '); + } else if (char === '/' && text[i + 1] === '/') { + comment = true; + result.push(' '); + } else { + result.push(char); + } + } + return result.join(''); +} + +module.exports = { codeOnly }; -- cgit v1.3.1-4-g156e