Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest changes broke image pasting on macOS #58

Closed
marcinjahn opened this issue Dec 26, 2021 · 14 comments
Closed

Latest changes broke image pasting on macOS #58

marcinjahn opened this issue Dec 26, 2021 · 14 comments

Comments

@marcinjahn
Copy link

Since the last update I cannot paste images into markdown anymore on macOS Monterey.
I see the following logs:

[12-26 17:27:01] Cannot found script for darwin
[12-26 17:27:01] getClipboardContentType
[12-26 17:27:01] null

A couple days ago it worked perfectly fine.

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

Mea culpa. I have accidentally removed support for it in #54 by removing this codepath.

It will be fixed soon.

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

@marcinjahn

You can test the fix by running

git clone https://github.com/knyzorg/vscode-markdown-paste-image
cd vscode-markdown-paste-image
npm i
npx vsce package
code --install-extension ./vscode-markdown-paste-image-0.15.2.vsix

@marcinjahn
Copy link
Author

@knyzorg The error is a bit different now:

12-26 20:03:01] "vscode-markdown-paste" is now active!
[12-26 20:03:01] No scipt exists for darwin
[12-26 20:03:01] Clipboard Type:
[12-26 20:03:01] -1
[12-26 20:03:04] /Users/marcin/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res/mac.applescript: /Users/marcin/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res/mac.applescript: cannot execute binary file

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

What happens when you try running osascript /Users/marcin/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res/mac.applescript? Do you encounter the same error?

@marcinjahn
Copy link
Author

~/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res
❯ osascript /Users/marcin/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res/mac.applescript


~/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res

It executes properly (I passed no arguments like in your example).

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

@telesoho Do you have a macbook you can test with? I'm not sure why this is happening. It seems to work from CLI but not from the extension.

@marcinjahn
Copy link
Author

@knyzorg I think there is some issue with the choice of executor. I logged the ${shell} ${options.join(" ")} line of
the runCommand function. I got sh /Users/marcin/.vscode/extensions/telesoho.vscode-markdown-paste-image-0.15.2/res/mac.applescript /Users/marcin/tmp/2021-12-26-20-20-59.png. It should use osascript instead of sh I guess.

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

@marcinjahn I did some changes. Can you pull and try again?

@marcinjahn
Copy link
Author

@knyzorg Yes, that works. Actually, I started creating a branch with that fix, but you were faster. Also, you fixed more switch cases than that single place.

@marcinjahn
Copy link
Author

@knyzorg Even though the functionality works, the log is a bit confusing:

[12-26 20:37:32] "vscode-markdown-paste" is now active!
[12-26 20:37:32] No scipt exists for darwin
[12-26 20:37:32] Clipboard Type:
[12-26 20:37:32] -1

"No script exists"?

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 26, 2021

The way this extension is designed, it expects to have multiple scripts for each OS.

One for

  • Detecting clipboard types
  • Pasting images
  • Pasting rich text
  • Pasting plain text

The only one we have for Mac is pasting images. So the way it works is it fails detect the clipboard type for Mac and falls back to attempting to extract plain text, which if fails, runs the paste image script.

I'm not very good with Macs, so someone will need to write the other scripts.

@marcinjahn
Copy link
Author

Yeah, I see that in code. I'm not good neither, today was the first time I saw actual AppleScript code :)

@vezaynk
Copy link
Collaborator

vezaynk commented Dec 27, 2021

The fix has been merged

@vezaynk vezaynk closed this as completed Dec 27, 2021
@JeffersonDing
Copy link
Contributor

Having the same issue on macOS Monterey on version 0.18.6. Copy past image works as expected but download image results in output

[04-01 00:24:05] "vscode-markdown-paste" is now active!
[04-01 00:24:05] No scipt exists for darwin
[04-01 00:24:05] Clipboard Type:
[04-01 00:24:05] -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants