From 481b16e0c44342ca9f569f8bebacde8b1e6d23d0 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 14 Apr 2026 11:46:47 +0900 Subject: [PATCH] fix: Webview hotfix for regex flags (v2.1.2) --- src/extension.ts | 16 ++++++++-------- test.js | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 test.js diff --git a/src/extension.ts b/src/extension.ts index 936ffad..df5d990 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1320,15 +1320,15 @@ let loader=null,sending=false,pendingFiles=[]; /* Syntax Highlighting (lightweight) */ function highlight(code,lang){ let h=esc(code); - h=h.replace(/(\\\\/\\\\/[^\\\\n]*)/g,'$1'); - h=h.replace(/(#[^\\\\n]*)/g,'$1'); - h=h.replace(/(\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\/)/g,'$1'); + h=h.replace(/(\\/\\/[^\\n]*)/g,'$1'); + h=h.replace(/(#[^\\n]*)/g,'$1'); + h=h.replace(/(\\/\\*[\\s\\S]*?\\*\\/)/g,'$1'); h=h.replace(/("[^&]*?"|'[^&]*?')/g,'$1'); - h=h.replace(/\\\\b(function|const|let|var|return|if|else|for|while|class|import|export|from|default|async|await|try|catch|throw|new|this|def|self|print|lambda|yield|with|as|raise|except|finally)\\\\b/g,'$1'); - h=h.replace(/\\\\b(\\\\d+\\\\.?\\\\d*)\\\\b/g,'$1'); - h=h.replace(/\\\\b(True|False|None|true|false|null|undefined|NaN)\\\\b/g,'$1'); - h=h.replace(/\\\\b(String|Number|Boolean|Array|Object|Map|Set|Promise|void|int|float|str|list|dict|tuple)\\\\b/g,'$1'); - h=h.replace(/([=!<>+\\\\-*/%|&^~?:]+)/g,'$1'); + h=h.replace(/\\b(function|const|let|var|return|if|else|for|while|class|import|export|from|default|async|await|try|catch|throw|new|this|def|self|print|lambda|yield|with|as|raise|except|finally)\\b/g,'$1'); + h=h.replace(/\\b(\\d+\\.?\\d*)\\b/g,'$1'); + h=h.replace(/\\b(True|False|None|true|false|null|undefined|NaN)\\b/g,'$1'); + h=h.replace(/\\b(String|Number|Boolean|Array|Object|Map|Set|Promise|void|int|float|str|list|dict|tuple)\\b/g,'$1'); + h=h.replace(/([=!<>+\\-*/%|&^~?:]+)/g,'$1'); return h; } diff --git a/test.js b/test.js new file mode 100644 index 0000000..a33d953 --- /dev/null +++ b/test.js @@ -0,0 +1 @@ +`h.replace(/(\/\/[^\n]*)/g)`