olivierkes / manuskript

A open-source tool for writers
http://www.theologeek.ch/manuskript
GNU General Public License v3.0
1.71k stars 226 forks source link

Improve file selection on import dialog #1215

Open FastusNumen opened 9 months ago

FastusNumen commented 9 months ago

The issue came about when I was importing a file. I had a few .odt files to import with Pandoc and for one of those I accidentally forgot to specify the format, so it was left as Markdown. When the window to choose the file opened, instead of only showing .md and .txt files, it showed all formats, and when I clicked on a .odt and tried to open it, the program crashed.

OS: Windows 11 Manuskript version: 0.15.0

Log: 2023-09-11 14:19:28,107 - manuskript.logging - CRITICAL - An unhandled exception has occurred! Traceback (most recent call last): File "manuskript\ui\importers\importer.py", line 133, in selectFile File "manuskript\ui\importers\importer.py", line 239, in preview File "manuskript\ui\importers\importer.py", line 295, in startImport File "manuskript\importer\markdownImporter.py", line 69, in startImport File "codecs.py", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 10: invalid start byte

TheJackiMonster commented 7 months ago

Well it seems like you tried to import a Markdown file but selected an OpenDocument file. Beware the import dialog shows the currently selected format on the upper left before you select any file via the file dialog. I agree that the file dialog should filter files depending on that format. Also it would be better to not crash the application on wrong file selection.

But otherwise this seems to be user error. If you have Pandoc installed, you should be able to select ODT as format before selecting an .odt file for import. Hope this helps.

FastusNumen commented 7 months ago

Yes, I knew that. I thought it was better to remove the option to choose files from different formats though, since mistakes happen. Thanks for the explanation anyway.