idleberg / vscode-applescript

Language syntax and snippets for AppleScript
https://marketplace.visualstudio.com/items?itemName=idleberg.applescript
MIT License
70 stars 8 forks source link

Support unsaved files #9

Closed fabiospampinato closed 6 years ago

fabiospampinato commented 6 years ago

If I open a new editor, and set the language mode to AppleScript I'm still not able to run the script until I save the actual file to the disk.

It would be great if this extension fully supported unsaved editors.

nicolinuxfr commented 6 years ago

I never thought it was an issue, but you're right, it would be great if the code as it is in the editor was used when running the script.

Right now, the run uses what is saved on disk, not what is the editor. If you forget to save the script before running it, the changes are not applied, which is weird.

So if it is possible, it would be a great addition ! 👍

fabiospampinato commented 6 years ago

I think it's definitely possible, the extension could just copy the content of the editor, save it automatically in a temporary file, and execute that.

idleberg commented 6 years ago

Thanks for the input. It's possible without saving the file and I got it working already. I'm not yet sure whether a user might want to keep the old behaviour, so I'm thinking about adding a fallback option. Either way, expect a new version today or tomorrow!

nicolinuxfr commented 6 years ago

I tried the update, but it does not seem to work for my case, unsaved changes are still not used when running the script.

Have I missed something ?

idleberg commented 6 years ago

Have I missed something ?

There were two broken 0.11 releases, but as of 0.12, I had no problems (tested on two Macs)

idleberg commented 6 years ago

Been away for a couple of days, what's the status on this? Everything works fine for me:

demo

(note the dot denoting the file as unsaved)

nicolinuxfr commented 6 years ago

Sorry, I did not take the time to test again.

And sorry one more time, I realised watching your video that I was not using the correct function. 🤦‍♂️

I was using the standard "Run code" from VSCode and not the "AppleScript: Run Script" from this extension.

So now that I have changed my shortcuts, it works indeed just fine when I do not save changes. Thanks for that ! 👍

fabiospampinato commented 6 years ago

It now runs the current script, but if I open a new file and I switch the language to applescript the buttons in the tab bar do not appear until I save it.

idleberg commented 6 years ago

@fabiospampinato This is probably a bug in vscode, but you can always invoke the commands provided by this package from the command palette