lostintangent / wikilens

🔎 VS Code extension that provides a Roam/Obsidian-like markdown-based notetaking experience for github.dev and VS Code
https://aka.ms/wikilens
128 stars 8 forks source link

[[object Object]] Cannot read properties of undefined (reading 'document') - Preview fails when setting markdown preview by default #32

Open tsathis opened 2 years ago

tsathis commented 2 years ago

According to this SO question, to make VS Code preview markdown by default, I added the following settings:

{
    "workbench.editorAssociations": {   
        "*.md": "vscode.markdown.preview.editor",
    }
}

And above setting works as expected when wikilens is disabled:

image

However, when wikilens is enabled, the markdown preview is not showing for the files that have links to another markdowns!

image

stack trace: TypeError: Cannot read properties of undefined (reading 'document')
    at Object.replace (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:399312)
    at t.rendererRule (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:12103)
    at Object.e.renderer.rules.<computed> [as wikilens-links] (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:12699)
    at s.renderInline (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1257228)
    at s.render (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1257632)
    at t.MarkdownEngine.render (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1362679)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async t.MarkdownContentProvider.markdownBody (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1383181)
    at async t.MarkdownContentProvider.provideTextDocumentContent (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1382250)
    at async m.updatePreview (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1371304)

mainThreadExtensionService.ts:79 [[object Object]]Cannot read properties of undefined (reading 'document')
TypeError: Cannot read properties of undefined (reading 'document')
    at Object.replace (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:399312)
    at t.rendererRule (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:12103)
    at Object.e.renderer.rules.<computed> [as wikilens-links] (c:\Users\tharindusathis\.vscode\extensions\lostintangent.wikilens-0.0.5\dist\extension.js:2:12699)
    at s.renderInline (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1257228)
    at s.render (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1257632)
    at t.MarkdownEngine.render (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1362679)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async t.MarkdownContentProvider.markdownBody (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1383181)
    at async t.MarkdownContentProvider.provideTextDocumentContent (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1382250)
    at async m.updatePreview (c:\Users\tharindusathis\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\markdown-language-features\dist\extension.js:1:1371304)

And after removing the setting mentioned at top the preview and extension works as expected:

image


These are the two md files that I have shown above:

parent.md:

# parent.md

I have one child link:

- [[child1]]

child1.md:

# Child1

This is mentioned in parent!