From 6aa970645dce82153c6cbe2b959bab1c406727ad Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Thu, 22 Feb 2024 21:27:41 -0800 Subject: [PATCH] Fix issue where multi-line definitions with the same name but different types were dropped Occurs because .indexOf(line) returns the first instance of this line, but there may be multiple instances. Need to track the correct offset to begin the search. --- index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e52a15b..f364fdd 100644 --- a/index.html +++ b/index.html @@ -260,8 +260,11 @@ function getEvents(code) { const events = new Set(); + let position = 0; let strict = false; for (let line of code.split('\n')) { + const originalLineLength = line.length; + position += originalLineLength; line = line.trim(); if (line === '') { continue; @@ -272,7 +275,7 @@ } // Basic lookahead for event definitions that span multiple lines if ((line.match(/\(/g)?.length ?? 0) > (line.match(/\)/g)?.length ?? 0)) { - const start = code.indexOf(line); + const start = code.indexOf(line, position - originalLineLength - 1); const end = code.indexOf(')', start); const lookaheadLine = code.substring(start, end + 1).replaceAll('\n', ''); try { -- 2.47.3