asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
326 stars 98 forks source link

No preview of .adoc files when open remote repository in VS Code Web #805

Closed OldKrab closed 10 months ago

OldKrab commented 10 months ago

When i open remote repository from github on vscode.dev, the preview of .adoc files is not displayed:

Screenshot

![image](https://github.com/asciidoctor/asciidoctor-vscode/assets/48640725/87972cba-5b1c-4cac-9b0d-6b3f6a41233d)

If refresh page at this state, we can see error message in Preview window:

Screenshot

![image](https://github.com/asciidoctor/asciidoctor-vscode/assets/48640725/357e031a-3376-41e2-b9ac-dc2fc2f51733)

When i create new empty file without saving it as a real file, preview works fine, until i save it:

Screenshot

![image](https://github.com/asciidoctor/asciidoctor-vscode/assets/48640725/99080f0a-3a28-4af1-922c-041a2183141f)

Steps to reproduce:

1) Open vscode.dev 2) Click "Open Remote Repository" in Explorer panel 3) Click "Open Repository from Github" and select any repo 4) Open any .adoc file and click Preview button

ggrossetie commented 10 months ago

I can reproduce this issue. The underlyon error seems to be:

D.P.onmessage @ webWorkerExtensionHost.ts:213
extHostFileSystemConsumer.ts:241 Uncaught (in promise) Unavailable (FileSystemError): Error: No file system handle registered (/asciidoctor)
    at p.e (../../../vs/workbench/api/worker/extensionHostWorker.js:82:27804)
    at Object.stat (../../../vs/workbench/api/worker/extensionHostWorker.js:82:24551)
e @ extHostFileSystemConsumer.ts:241
stat @ extHostFileSystemConsumer.ts:60
Promise.then (async)
step @ preview.ts:3
fulfilled @ preview.ts:3
Promise.then (async)
step @ preview.ts:3
eval @ preview.ts:3
__awaiter @ preview.ts:3
doUpdate @ preview.ts:355
update @ preview.ts:253
preview @ previewManager.ts:62
eval @ showPreview.ts:41
eval @ showPreview.ts:3
__awaiter @ showPreview.ts:3
showPreview @ showPreview.ts:22
execute @ showPreview.ts:56
h @ extHostCommands.ts:248
$executeContributedCommand @ extHostCommands.ts:313
S @ rpcProtocol.ts:456
Q @ rpcProtocol.ts:441
M @ rpcProtocol.ts:371
L @ rpcProtocol.ts:297
eval @ rpcProtocol.ts:161
z @ event.ts:1138
fire @ event.ts:1169
s.port1.onmessage @ extensionHostWorker.ts:195
commons-app~pfHelper-HttpManager.js.5254ed0a698fdcccc447.js:1 
ggrossetie commented 10 months ago

I found the root cause, the AsciidoctorConfig feature is not compatible with VS Code Web. More precisely, this line:

https://github.com/asciidoctor/asciidoctor-vscode/blob/d0360933a4c3ab3933504f45496069b6c217805f/src/features/asciidoctorConfig.ts#L51

ggrossetie commented 10 months ago

We should probably mimick what the Markdown extension is doing with a dedicated entry point for the web/browser extension:

https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/src/extension.browser.ts

That way we can decide which feature we want to enable on the web/browser extension.