Go.novaextension icon indicating copy to clipboard operation
Go.novaextension copied to clipboard

Nova opens go.mod in video player

Open flyx opened this issue 2 years ago • 3 comments

When I click on a go.mod file, Nova opens a dysfunctional video player interface instead of an editor.

Since this extension provides a syntax for go.mod files, I assume that either a recent Nova update has broken this, or there is some setting I am unable to find to fix this.

I am mainly opening this issue to see whether this is a problem with my personal configuration or affects other people as well.

flyx avatar Dec 01 '21 19:12 flyx

Hi there!

Indeed, that's a 'known' problem — it happens to me, too!

  • It's not a new issue, it's been around for quite a while...
  • I've actually reported it to Panic... I only wish I remembered where I reported it... I think it was by email
  • This is allegedly from some sort of issue when you install 'something' that uses the .mod extension as an audio file. In my case, it was a digital audio workstation (DAW), which I used for a while. But even after removing it as well as all the references to it, and specifically assigning Nova to the .mod extension, macOS still assigns it a 'music' symbol (and so does Nova). I've also noticed that other applications recognise the .mod extension as being 'music', e.g. VLC, QuickTime, and even Skype...

That said, I usually 'fix' this by doing the following:

  1. Open Finder
  2. Within Finder, change to the directory of your Go project, select go.mod, and right-click on it and select Get Info (or press -I); further down on the Info panel, where you have the Open with: dropdown selection, choose Other..
  3. Now choose Nova from the list of applications. You might need to press the button that says Options and then select All Applications so that you can select Nova from the list. This should now at least guarantee that Nova is the application always launched for .mod files (and theoretically it ought to change the icon, but in my case this doesn't happen).
  4. Back to the Info panel for go.mod, you should now see Nova being selected; just below it, beneath the label Use this application to open all documents like this one., click on Change All...
  5. Now open Nova and, making sure that you have the Go extension active, then go to Preferences > Editor and then the Files tab.
  6. Add a new Custom Type for the mod extension; if you have the Go extension active, you should have Go Modules List on the many available syntaxes.
  7. Try opening a go.mod file in Nova; it should now correctly display the text and not that weird, non-functioning audiovisual player, even though in the sidebar it still shows an icon with a musical note.

However, I cannot guarantee that this will work consistently all the time...

There are some (old) instructions on how to correctly assign file extensions to specific applications and their respective icons. However, this is something that has to be done 'inside' the Nova code, not via an extension/plugin. I believe that the Panic developers may have put some code in Nova to invoke the Launch Services and register new file extensions when a Nova extension uses it (which would be the way I'd do it, if I were Panic!), and un-register it when the Nova extension is deactivated. But I have no idea how exactly Nova does it. It's conceivable that Nova will first ask the Launch Services if a file extension is already registered before asking it to register that file extension on Nova's behalf; this would explain why 'nothing happens' when a different application already has requested it.

However, this is not 100% consistent with Apple's description of how the Launch Services are supposed to handle multiple applications registering the same file extension; unlike what happens under other operating systems (Windows, for instance), you can have several applications notifying the Launch Services that they are able to open a specific file extension; that's how macOS 'knows' what are the 'recommended' applications to launch a specific file, for instance, and how the system can notify the user when it's unknown if a specific application can or cannot launch a certain file. All that 'magic' is supposed to happen in the background. For instance, this is how Nova registers with the Launch Services that anything finishing with .novaextension is to be regarded by macOS as being a very special kind of folder that only Nova 'knows' how to open (or, similarly, how Photoshop and Illustrator register special files as being their plugins).

In fact, if you open /Applications/Nova.app/Contents/Info.plist, you can see all the file extensions that Nova registers with the Launch Services when Nova is installed; these use the key CFBundleTypeExtensions, and you can see that there are a lot of them (actually, I was surprised that .go is part of the list!...). Note that this file is read-only; if you change it, you tamper with the many levels of digital signatures, and macOS will refuse to launch Nova. Because so many file extensions are, in fact, provided by popular Nova extensions developed by third parties — and not by Panic — I can only assume that Panic periodically updates that list with subsequent Nova upgrades.

Using Info.plist is the easiest way for an application to register with the Launch Services that it is able to open certain types of files. As said, it's not relevant if both Nova and the TextEdit register .txt as 'their' files; it will be up to the user to decide which application they will prefer to open .txt files, at a later stage; for the Launch Services, it's only important to figure out which applications are able to open such files. The user will still have the option to change that from the Get Info panel. There is an algorithm to figure out which application to launch, according to the article I've posted — which is for the very earliest versions of macOS, so things might have changed in the past two decades!

However, this is not the only way of registering file extensions, it's just the easiest. You can do that programatically, dynamically, depending on specific circumstances. In the case of Nova, it would make sense to register new file extensions declared by Nova extensions, once such extensions are installed and activated. But I don't really know if this is the case (much less why .mod seems to be a weird sort of exception, being considered both by the operating system and Nova to be some kind of audiovisual file). Nevertheless, I'm going to ask on the Nova developer forums 😃 Maybe some helpful developer is able to figure out what's going on, and if there is a way, via a Nova extension, to somehow change the behaviour of the Launch Services...

Please take into account that I'm not a professional Apple developer (not even an amateur one!). All the above comes mostly from reading documentation and a few StackExchange answers on the subject. I have no experience whatsoever in writing Apple applications 😅 so it's possible that everything I wrote is just plainly wrong.

But please go ahead and try the 7 steps above for a possible 'fix'. With luck, you'll get things working, even if the icon will refuse to change. For now, this is the 'best' answer I can give to your issue — one that, as you so well pointed out, very likely affects most macOS users (since it's highly likely that practically everybody will have installed at least one other application that registered .mod as some kind of audiovisual file).

Oh, and by the way, historically, MOD files were used on the Commodore Amiga to store music tracks. It was a very popular format at the time, and lots of different platforms tended to use the same file format, or, at least, be able to convert to and from it. VLC, for instance, is still perfectly able to 'play' Amiga MOD files; it's not surprising, therefore, that some application might have registered .mod as being an audiovisual file, and therefore macOS (and Nova) 'think' that it should get a musical note icon. Apparently, Nova has some sort of built-in audiovisual player — so when Nova is requested to open a .mod file, it launches that player, but, of course, a go.mod file is just text, so it won't 'play'.

You can also get a few real Amiga MODs to play from https://modarchive.org/ — VLC will play them flawlessly. I've tried, though, but Nova's built-in audiovisual player cannot (neither can QuickTime, at least not in my system). I suspect that .mod files — which are flagged by the Finder as MOD Audio File — are intrinsically 'audiovisual files', thus the libraries used by Panic will, by default, call their embedded audiovisual player every time a file is opened that is flagged as being 'audio file' or 'video file'.

Anyway, sorry for the delay in answering — and for writing such an elaborate answer...

GwynethLlewelyn avatar Dec 05 '21 22:12 GwynethLlewelyn

Yeah so since opening this issue, I figured I can go in Novas Preferences > Editor > Files and create a custom file type specifically for go.mod, just like you said. This fixes it.

Of course, the extension should do this automatically but this depends on Nova letting it, which currently does not seem to be the case. So the proper state of this issue is probably „blocked by upstream“.

I figure this has happened when I installed VLC.

Thanks for all the text, you seem to have enjoyed writing it :)

flyx avatar Dec 06 '21 00:12 flyx

You're right — as far as I know, extensions do not have the ability (yet) to add custom file types to the editor in that way. Probably they're not even meant to ever do that, I don't know. I'll ask around in the dev forums again and see if someone from Panic replies (sometimes, @Logan does).

I've flagged this as blocked by upstream as you so very well suggested and I'll keep it open just to see if it's 'fixable' in future versions of Nova...

And aye, I did enjoy writing the answer lol :-)

GwynethLlewelyn avatar Jan 11 '22 10:01 GwynethLlewelyn