When trying to open a binary file in Visual Studio Code, the following message will show:
The file will not be displayed in the editor because it is either binary, very large or uses an unsupported text encoding
This is likely a protection to avoid the editor from freezing.
I would love to decode the file before showing it in the editor and have a function ready to handle that. The problem is, that I never have a chance to run my function since the following code never triggers:
vscode.workspace.onDidOpenTextDocument(function (doc) {
if (doc && doc.fileName.endsWith('.scpt')) {
console.log("You're trying to open a binary AppleScript file")
}
});
Unfortunately, the API doesn't provide an equivalent event to onWillSaveTextDocument
for opening files, which would fire before the message above shows. Does anybody know of a different solution?