From 4d32246cfc58500901e6ec3e8035f1d5ecfed845 Mon Sep 17 00:00:00 2001 From: everestmcarthur <280397636+everestmcarthur@users.noreply.github.com> Date: Sat, 1 Aug 2026 20:29:58 -0400 Subject: [PATCH] Key Inspector: fix Eval breaking on smart-quote autocorrect from mobile keyboards --- plugins/key-inspector/src/lib/evalTool.ts | 16 +++++++++++++++- plugins/key-inspector/src/ui/Settings.tsx | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/key-inspector/src/lib/evalTool.ts b/plugins/key-inspector/src/lib/evalTool.ts index 02349a3..2e20138 100644 --- a/plugins/key-inspector/src/lib/evalTool.ts +++ b/plugins/key-inspector/src/lib/evalTool.ts @@ -47,7 +47,21 @@ function safeStringify(value: any): string { * expression, a `return ...`, or `await`-ing something all work. Never runs anything on its own - * only what's typed in and manually run here. */ -export async function runEval(code: string): Promise { +// Android/iOS keyboards commonly have "smart punctuation" that silently swaps straight quotes for +// curly ones as you type, even with autoCorrect disabled on some keyboards (GBoard's smart +// punctuation is a separate setting) - that turns "foo" into “foo”, which is a different character +// to the JS parser and throws "non-terminated string" with no indication why. Normalizing common +// substitutions back to their plain-ASCII equivalents before compiling means typing/pasting code on +// a phone keyboard doesn't silently produce invalid syntax. +function normalizeSmartPunctuation(code: string): string { + return code + .replace(/[‘’]/g, "'") + .replace(/[“”]/g, '"') + .replace(/[–—]/g, "-"); +} + +export async function runEval(rawCode: string): Promise { + const code = normalizeSmartPunctuation(rawCode); try { const fn = new Function( "findByProps", diff --git a/plugins/key-inspector/src/ui/Settings.tsx b/plugins/key-inspector/src/ui/Settings.tsx index 62f2465..0745ebc 100644 --- a/plugins/key-inspector/src/ui/Settings.tsx +++ b/plugins/key-inspector/src/ui/Settings.tsx @@ -66,6 +66,9 @@ function EvalSection() { value={code} onChange={setCode} multiline + autoCorrect={false} + autoCapitalize="none" + spellCheck={false} />