telesoho / vscode-markdown-paste-image

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

Fix #65 wslpath returning newlines #66

Closed pearj closed 2 years ago

pearj commented 2 years ago

In #65 I discovered that on my system that wslpath was returning trailing newlines, this fix trims those newlines.

vezaynk commented 2 years ago

@pearj @telesoho @manuth

This appears to be a regression from #61 which incidentally removed trimming from runCommand. The trim should happen there, not in wslpath. It's likely there are other bugs that this currently causing.

I haven't been very actively lately. I'm working on a new way to handle cross-platform pasting without the need for scripts.

pearj commented 2 years ago

Thanks @knyzorg, that makes more sense, I was wondering how it ever worked.

I pushed up a new commit switching back to trimming on runCommand, see #67.

What approach are you trying to use that doesn't use scripts? Directly calling operating system apis like: https://www.npmjs.com/package/win32-api or https://github.com/node-ffi-napi/node-ffi-napi?

vezaynk commented 2 years ago

Good question @pearj,

Node-ffi is exactly what I would like to do. Apparently, there doesn't exist a single package that does it for clipboard access.

I have played around with https://github.com/dacap/clip/ and can't even get the examples working. I haven't given up on it yet though.

The second thing I'm trying out is using chromium to handle the copy-pasting via the devtools protocol. Which is showing some promise but requires weird techniques (i.e. simulating CTRL+V) to extract from the clipboard as the native API has too many limitations.

But ideally, I'm trying to find a cross-platform C/C++ library and wrap it in node-ffi. Apparently such libraries are few are far between.

Send me an email if this is something you want to work on together, I'll share the notes I have so far.