telesoho / vscode-markdown-paste-image

Smartly paste for Markdown.
MIT License
138 stars 41 forks source link

Does Not Work With Remote-WSL Extension #35

Closed RyanPersson closed 2 years ago

RyanPersson commented 4 years ago

Hello! This extension doesn't work out of the box with the Windows Subsystem for Linux extension suite. I am using VScode 1.48, windows 10, WSL & the Remote - WSL extension.

I believe the issue is that this extension, by default, tries to force you to run it on the wsl-remote side which does not have access to the windows clipboard.

I was able to fix the issue by adding this to settings.json:

"remote.extensionKind": {
        "telesoho.vscode-markdown-paste-image": ["ui"],
    }

This forces the extension to run on the UI/Windows side where it has access to the windows clipboard.

This could be fixed by setting vscode-markdown-paste-image to run on the ui/windows side by default when remote extensions are installed.

In the meantime, the above local fix works for wsl if anyone else is having the same issue.

[EDIT: after experimenting with it a bit more, it doesn't actually work, even with this fix. Changing the settings.json so it runs on the ui side lets you access the clipboard. But it does not actually save the image file that you create.]

telesoho commented 4 years ago

I have no windows 10, and never use WSL before. I think the extension do not get the correct clipboard contents on WSL. Could you please check it for me?

  1. Open vscode developer tools(Ctrl+shift+i)
  2. Try to paste an image into a markdown file.
  3. If the extension get the correct clipboard contents, the console log will get some output like this:

image

RyanPersson commented 4 years ago

When Running wsl-remote. I create an image in the windows clipboard using the screen snipping tool.

When I try to paste that image into a markdown file via Ctrl+Alt+V, the UI takes me through the options for saving/pasting an image. It allows me to name the filepath & then creates an image style link. When I navigate to where the image is supposed to be, vscode says "an error occured while loading this image." & navigating to the directory through any other file explorer shows that no image file was actually created.

I've attached a screenshot of the console output as you requested as well as vscode trying to view the image.

image

image

I think that you are correct that the extension doesn't correctly get the image clipboard contents in WSL. The extension works correctly when I use it without WSL

telesoho commented 4 years ago

Thank you for your help. Base on the screenshots you send, while the extension use NodeJS.Process.platform property to detect running platform in WSL, it got 'win32' not 'linux', so it call windows batch to get image clipboard in WSL, obviously it got nothing. I can't fix this problem now.

vedal commented 3 years ago

@telesoho thank you so much for this nice plugin. I must however confirm that it doesn't work on vscode remote (I'm not using WSL, just straight SSH). This is the error message:

[Extension Host] Error:     at ChildProcess.<anonymous> (/server/user/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.12.3/out/paster.js:39:24)    at ChildProcess.emit (events.js:315:20) at maybeClose (internal/child_process.js:1021:16)   at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

log.ts:296   ERR Cannot read property 'document' of undefined: TypeError: Cannot read property 'document' of undefined
    at f (/server/user/.vscode-server/extensions/yzhang.markdown-all-in-one-3.4.0/dist/extension.js:1:296405)
    at p (/server/user/.vscode-server/extensions/yzhang.markdown-all-in-one-3.4.0/dist/extension.js:1:293505)
    at g (/server/user/.vscode-server/extensions/yzhang.markdown-all-in-one-3.4.0/dist/extension.js:1:295197)
    at v.provideCodeLenses (/server/user/.vscode-server/extensions/yzhang.markdown-all-in-one-3.4.0/dist/extension.js:1:297961)
    at u.provideCodeLenses (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:86:157705)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:86:180749
    at Ie._withAdapter (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:86:179343)
    at Ie.$provideCodeLenses (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:86:180725)
    at u._doInvokeHandler (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:90:12794)
    at u._invokeHandler (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:90:12478)
    at u._receiveRequest (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:90:11094)
    at u._receiveOneMessage (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:90:9931)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:90:8032
    at b.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:57:1836)
    at E.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:15496)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:105:29750
    at b.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:57:1836)
    at E.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:15496)
    at t._receiveMessage (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:20754)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:17640
    at b.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:57:1836)
    at acceptChunk (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:12861)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:65:12209
    at b.fire (/server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:57:1836)
    at /server/user/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/out/vs/server/remoteExtensionHostProcess.js:105:18995
    at afterWrite (_stream_writable.js:490:5)
    at onwrite (_stream_writable.js:470:7)
    at InflateRaw.afterTransform (_stream_transform.js:98:3)
    at Zlib.processCallback (zlib.js:578:8)

I'm also on Windows with Linux server... Is this the same error as @RyanPersson ?

RyanPersson commented 3 years ago

Hello @vedal , this isn't the same error that I had using the WSL remote extension. Does using VScode through SSH even support uploading images through the SSH tunnel? That doesn't seem like something that would be implementable at all, but maybe I'm wrong?

What if instead, the extension was set up to post images to a free hosting service like imgur, and then automatically just pasted the link to the web hosted image? That would probably resolve all issues with SSH and comparable uses.

vedal commented 3 years ago

@RyanPersson I suppose youre right that its a different problem... Not sure how vscode ssh works under the hood, but they do suggest rsync can be used aling with it. Maybe by storing a temp-file on local, then rsyncing? https://code.visualstudio.com/docs/remote/ssh#_can-i-use-local-tools-on-source-code-sitting-on-the-remote-ssh-host

I suppose the solution you posted with imgur would work, similar to clients like Quiver, but you'd lose the nice control of having all images right there in the folder.

For the short-term, there should at least be an error message when used on remote, as it now fails silently.

JeffersonQin commented 3 years ago

Well, to me, I think the problem of SSH and WSL are different. For WSL, you still have access to Windows through bash, because you can evoke powershell.exe or cmd.exe (etc.) to access Windows, which is your editing environment. However, in the case of SSH, the extensions can only access the target environment, but not the host environment (editing environment).

And to implement the functionalities for WSL, we have to separate it into two steps:

I have added the similar support in another project: https://github.com/PicGo/PicGo-Core/pull/87