]> git.ardis.lu - event-hashes/commitdiff
Skip lookahead if no closing parenthesis is found
authorArdis Lu <ardisglu@gmail.com>
Thu, 4 Apr 2024 05:43:28 +0000 (22:43 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 4 Apr 2024 05:43:28 +0000 (22:43 -0700)
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

index 210fb50c7f72f26d4c62e318d4cb06cb5194afea..bdc70217484a1434ec84b30638562b243df5a4b7 100644 (file)
         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);
This page took 0.056839 seconds and 4 git commands to generate.