aboutsummaryrefslogtreecommitdiff
path: root/plugin/src/lexical.js
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 05:58:39 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 05:58:39 +0000
commite52266d8ce8823866b2dad3e04ffc78438e08397 (patch)
tree6fbda74ac31a1d5db2e765d5ca086ae45df861ff /plugin/src/lexical.js
parentbe8154fac8a0ea5eb3dddef4053f12d67102009d (diff)
feat(plugin): add keyword Tab indentation and selection formatting
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'plugin/src/lexical.js')
-rw-r--r--plugin/src/lexical.js33
1 files changed, 33 insertions, 0 deletions
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 };