Thunar design is stupid - by design.
The fault isn't entirely Thunar's. The design is rooted in the XDG specification: Association between MIME types and applications. This specifies a very dysfunctional and dangerous algorithm for determining the Default Application.
The problem is:
Once all levels have been checked, if no entry could be found, the implementation should pick the most-preferred .desktop files associated with the mimetype, taking into account added and removed associations as per the previous section.By 'most-preferred', one can only guess: the term isn't defined. The section Adding/removing associations provides and algorithm for listing applications 'in preference order' but it doesn't define how lists from multiple files are merged. Presumably the are appended, but this isn't stated. It doesn't define how duplicates (i.e. the same association specified in multiple mimeapps.list files) should be handled.
When associations are added from .desktop files with MimeType= including the given mime type, the specification does not say in what order these should be added.
As a result, the 'preferred order' is not well specified.
So, if no 'Default Application' has been specified in any 'mimeapps.list file, then the default application is the 'most-preferred' one in the list that does not have a well defined order.
Double clicking a file can open it with an appropriate app, then after some change (add/remove software, or whatever change) if that app can't be found for some reason, an effectively random app is used, instead of alerting the user that the default app cannot be found and forcing an explicit selection. This is dangerous.
The problem is that Thunar does nothing to clarify or disambiguate what will happen on double-click.
When you double-click a file, it is opened with a 'default' application - that is, without specifying an application, some application is used to open the file. I call that a 'default' application.
In fact, when one double-clicks, there are two cases:
- A 'Default Application' has been set and that is used to open the file
- No 'Default Application' has been set, in which case whatever application was last used to open the mime type of the file is used
That second case is the problem. The 'whatever application was last used' is effectively a default application, except that it is not saved as the 'Default Application' so that every time 'Open with...' is used to select a different application, without checking 'Use as default', the effective default application (i.e. whatever was used last) changes.
The two kinds of default are not well documented and the magic behaviour of 'Use as default' is not documented. The fact that there are two ways of determining the default application is not documented. Users are left with this unexplained, confusing behaviour.
The behaviour should be documented at Thunar - Working with Files and Folders, but it isn't. Instead, there are statements about 'the default action' without any clarification about the different kinds of default action or how to set them. Nothing is said at all about the difference between 'the default action' and the 'Default Action'.
See "Open with" always changes default
The Thunar 'Open with...' interface does not clearly indicate whether there is a 'Default Application' or not. It shows a list of applications that may be selected and one is the effective default but there is no distinction in the presentation between it being the configured 'Default Application' or merely the last application used.
To see the 'Default Application' for a mime type, it is necessary to open ~/.config/mimeapps.list and look for the section [Default Applications]. If the mime type is listed in this section, then it has a 'Default Application'. Otherwise, it just has whatever was used last.
The context menu option 'Set default application' sets the 'Default Application' and it also, despite the name, opens the file with the new 'Default Application'. It does not, as the name implies, merely change the default application.
The context menu option 'Open with other application...', with the checkbox 'Use as default for this kind of file' is redundant with 'Set default application': it changes the 'Default Application' and opens the file with the new 'Default Application'.
The file properties shows 'Open with:' but does not indicate whether the application is the 'Default Application' or merely 'the default application' - i.e. the application that was last used to open the type.
If you add a 'Custom Command', these are stored in '.desktop' files in ~/.local/applications. The file names begin with 'userapp-'.
Even worse: Open with > Open With Other Application... opens a dialog with title 'Open With' that has at the top an application under the heading 'Default Application' even when there is no 'Default Application' - there is only the application that was last used. This makes it totally confusing as to whether there is a 'Default Application' or not and makes the behaviour of selecting a different application with 'Open with' extremely mysterious. It is stupid by design.
You can delete .desktop files in ~/.local/applications, but then you must run 'update-desktop-database ~/.local/applications' to rebuild the cache of mime type / application associations. It is not clear what happens if an entry in ~/.config/mimeapps.list refers to a desktop file that has been deleted.
What would be a not-stupid design: If there is no default, then there is no default - double clicking a file with no default application should open a pop-up dialog that tells the user there is no default application so the double-click cannot open the file. The right click context menu should show a list of options for opening the file with none distinguished as the default application. On the other hand, if there is a default application, the right click context menu should clearly indicate the default application, and other options for opening the file.