Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/diffs/src/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ let renderOptions: WorkerRenderingOptions = {
maxLineDiffLength: 1000,
};

const EMPTY_REGEXP = /(?:)/;

self.addEventListener('error', (event) => {
console.error('[Shiki Worker] Unhandled error:', event.error);
});
Expand Down Expand Up @@ -71,6 +73,10 @@ async function handleMessage(request: WorkerRequest) {
} catch (error) {
console.error('Worker error:', error);
sendError(request.id, error);
} finally {
// Reset legacy RegExp last-match state so it cannot keep a highlighted
// source string alive after a highlight job completes.
EMPTY_REGEXP.exec('');
}
}

Expand Down
Loading