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;
}
// 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 {