From 66bd0f428fc4790725d8deeac8f7fde2937e58f6 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 3 Apr 2024 22:43:28 -0700 Subject: [PATCH] Skip lookahead if no closing parenthesis is found Fixes issue where an extra event is found while a user is typing an event, because substring(start, -1) captures the entire input and re-captures the first event in the input. --- index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.html b/index.html index 210fb50..bdc7021 100644 --- a/index.html +++ b/index.html @@ -321,6 +321,9 @@ if ((line.match(/\(/g)?.length ?? 0) > (line.match(/\)/g)?.length ?? 0)) { const start = code.indexOf(line, position - originalLineLength - 1); const end = code.indexOf(')', start); + if (end === -1) { // No closing parenthesis found + continue; + } const lookaheadLine = code.substring(start, end + 1).replaceAll('\n', ''); try { const normalizedEvent = normalizeEvent(lookaheadLine, strict); -- 2.47.3