Skip to content

Commit e48d9d8

Browse files
committed
preview, projectContext - Invalidate file cache for rendered files to ensure changes are picked up in preview mode
1 parent 56ebeec commit e48d9d8

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎src/command/preview/preview.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ export async function renderForPreview(
424424
pandocArgs: string[],
425425
project?: ProjectContext,
426426
): Promise<RenderForPreviewResult> {
427+
// Invalidate file cache for the file being rendered so changes are picked up.
428+
// The project context persists across re-renders in preview mode, but the
429+
// fileInformationCache contains file content that needs to be refreshed.
430+
// TODO(#13955): Consider adding a dedicated invalidateForFile() method on ProjectContext
431+
if (project?.fileInformationCache) {
432+
const normalizedFile = normalizePath(file);
433+
if (project.fileInformationCache.has(normalizedFile)) {
434+
project.fileInformationCache.delete(normalizedFile);
435+
}
436+
}
437+
427438
// render
428439
const renderResult = await render(file, {
429440
services,

0 commit comments

Comments
 (0)