"r.mimeType undefined" error when previewing some text files
Versions
- sushi-41.0 gjs-1.72.0 on Fedora 36.
- sushi-41.0 gjs-1.71.90 on latest GNOME OS nightly.
Steps to Reproduce
- Create a text file with some content and name it
test.txt
(e.g.echo 'test' > test.txt
). - Create a copy of the text file and name it
test.py
. - In Nautilus, select
test.txt
and press space bar, or run the commandsushi test.txt
. - Sushi will open a preview window showing the content of
test.txt
. - Keep the preview window open and select
test.py
in Nautilus, or run the commandsushi test.py
. - The preview window shows an error "Unable to display test.py, r.mimeType undefined".
- If the the preview window is not already open, nothing will show up when trying to preview
test.py
directly.
Troubleshooting
- This seems to happen to all text files not ending in
.txt
, as well as folders, but in Fedora 35 Sushi can preview both of them without the error. -
r.mimeType
seems to be used insrc/ui/mimeHandler.js
for querying the supported MIME types of the viewers for various formats insrc/viewers
. - Importing the viewers at
L37
results in an additional item__init__
, and later when the viewers are enumerated it will create this error. So this seems to happen for all file types that are not claimed by any of the viewers, including folders, and according to the later part in the code they should have been handled according to a parent type or by the fallback renderer. - I made a quick change as follows and it works. But I believe there should be a better way to import the folder without
__init__
in the first place, although I'm not familiar with GJS, or JS in general. Also this might be due to a recent change in GJS because Sushi version is not changed between Fedora 35 and 36.
-for (let i in imports.viewers)
- renderers.push(imports.viewers[i]);
+for (let i in imports.viewers) {
+ if (i != '__init__') {
+ renderers.push(imports.viewers[i]);
+ }
+ }