fix(completions): instantiate Slugger per file
Move Slugger instantiation inside the file loops to prevent state leakage between files, as Slugger is stateful.
This commit is contained in:
@@ -81,12 +81,15 @@ async function scanClientSide(): Promise<JournalCompletions> {
|
||||
const links: LinkCompletion[] = [];
|
||||
const sparkTables: SparkTableCompletion[] = [];
|
||||
const tagRegex = /<md-dice[^>]*>\s*([\s\S]*?)\s*<\/md-dice>/gi;
|
||||
const slugger = new Slugger();
|
||||
|
||||
for (const filePath of paths) {
|
||||
const content = await getIndexedData(filePath);
|
||||
if (!content) continue;
|
||||
|
||||
// Fresh slugger per file so duplicate headers across files don't
|
||||
// pollute each other.
|
||||
const slugger = new Slugger();
|
||||
|
||||
// Dice scan
|
||||
let match: RegExpExecArray | null;
|
||||
tagRegex.lastIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user