fix memory wiki empty related blocks (#78399)

Co-authored-by: Alex Knight <15041791+amknight@users.noreply.github.com>
This commit is contained in:
Alex Knight
2026-05-06 19:55:22 +10:00
committed by GitHub
parent 3323327f6b
commit 7a73b37f87
3 changed files with 22 additions and 0 deletions

View File

@@ -170,6 +170,24 @@ describe("compileMemoryWikiVault", () => {
);
});
it("does not rewrite empty source pages into related-only stubs", async () => {
const { rootDir, config } = await createVault({
rootDir: nextCaseRoot(),
initialize: true,
});
const emptySourcePath = path.join(rootDir, "sources", "empty.md");
const whitespaceSourcePath = path.join(rootDir, "sources", "whitespace.md");
await fs.writeFile(emptySourcePath, "", "utf8");
await fs.writeFile(whitespaceSourcePath, " \n\t", "utf8");
const result = await compileMemoryWikiVault(config);
await expect(fs.readFile(emptySourcePath, "utf8")).resolves.toBe("");
await expect(fs.readFile(whitespaceSourcePath, "utf8")).resolves.toBe(" \n\t");
expect(result.updatedFiles).not.toContain(emptySourcePath);
expect(result.updatedFiles).not.toContain(whitespaceSourcePath);
});
it("does not relate every page through a broad shared source", async () => {
const { rootDir, config } = await createVault({
rootDir: nextCaseRoot(),

View File

@@ -776,6 +776,9 @@ async function refreshPageRelatedBlocks(params: {
continue;
}
const original = await root.readText(page.relativePath);
if (original.trim().length === 0) {
continue;
}
const updated = withTrailingNewline(
replaceManagedMarkdownBlock({
original,