imlinhanchao / vsc-markdown-image

Easy to insert a image to markdown
https://marketplace.visualstudio.com/items?itemName=hancel.markdown-image
MIT License
209 stars 33 forks source link

`Get 0 images` when pasting image on Windows with Remote SSH #80

Closed joaociocca closed 1 year ago

joaociocca commented 1 year ago

The idea of your extension seemed perfect for the only functionality I feel is lacking on VS Code!

But when I try to paste a capture image (either with Alt+Shift+V or right-click > Paste Image), nothing happened.

I thought I'd then look on the VSCode Dev Tools and there it was: [Extension Host] Get 0 images workbench.desktop.main.js:87

image

When inspecting line 87, it shows the ondulated underline of an error:

image

Prettifying the code, the error seems to be on line 29860 of the workbench.desktop.main.js:

image

I'm not much of a programmer, but it seems the extension is using a Buffer() deprecated function? I tried to find this Buffer(), seems like there's only 2 occurences: line 51931 and line 246735

image

image

I'm running VS Code 1.73.1 on Windows 11 Pro 22H2 22621.819, but remoting into a Kali (based off Ubuntu, Linux kali 5.19.0-kali2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.19.11-1kali2 (2022-10-10) x86_64 GNU/Linux) session (which has xclip 0.13 installed).

Could this be related to the error I get when trying to run xclip in this session? I always get a Error: Can't open display: (null) message.

Any ideas on how to make it work?

imlinhanchao commented 1 year ago

Capture a image,and then execute this script https://github.com/imlinhanchao/vsc-markdown-image/blob/master/asserts/linux.sh like:

./linux.sh output.png 

Give me the output of command line,thks.

joaociocca commented 1 year ago

whoa, that was lightning fast. Hang on, gotta restore the VM.

Ok, grabbed the script, print in clipboard...

image

And, as expected, Error: Can't open display: (null)

imlinhanchao commented 1 year ago

I noticed you are using in a remote VM. Unfortunately, xclip requires an X desktop, so it won't work in a remote VM.

joaociocca commented 1 year ago

I followed some instructions from https://stackoverflow.com/questions/65468655/vs-code-remote-x11-cant-get-display-while-connecting-to-remote-server and got remote tmux to succesfully transfer content to my local clipboard

image

But when executing the linux.sh script you pointed to, all I get is a new error:

image

then I tried again and...

image

But it was only the text I had previously copied...

image

let's try again with the above image in the clipboard...

Yeah, no deal.

image

It's grabbing an even older content I copied from tmux (you can see it on the first print here)

(edit) I can definitely copy from remote and paste on local...

image

I forgot to mention that my tmux uses xclip - so here, plain and open piping text to xclip:

image

joaociocca commented 1 year ago

New error: "Could not load markdown it plugin". I tried searching for this, but couldn't find it. I found two "markdown-it-*" related, but not simply "markdown-it". image

The buffer warning seems to be a VS Code known issue, attempted to be fixed here, but still ongoing here.

joaociocca commented 1 year ago

HA! Found out that the functionality is on experimental and already working actually! <3 https://github.com/microsoft/vscode/issues/164843#issuecomment-1294460344

But thanks for developing this and for attempting to help me =) Keep being awesome!