pop-os / cosmic-files

WIP COSMIC file manager
GNU General Public License v3.0
109 stars 82 forks source link

[Bug] Double clicking scripts opens them in the default browser instead of the text editor regardless of the file extension or permissions #440

Open JoaoDelille opened 1 month ago

JoaoDelille commented 1 month ago

Cosmic-files version: Name : cosmic-files Version : 0.1.0~^20240829gitd923efa Release : 1.fc40 Architecture : x86_64 Size : 28 M Source : cosmic-files-0.1.0~^20240829gitd923efa-1.fc40.src.rpm Repository : @System From repo : copr:copr.fedorainfracloud.org:ryanabx:cosmic-epoch Summary : Libcosmic file manager

Issue/Bug description: Double clicking on a script will open it in the default browser. This does not depend on the file being marked as executable. This does not happen with regular text files. A file named "test.py" containing regular text opens in the text editor, however the same file will open in the default browser if it contains valid python code.

Steps to reproduce: Create two files, the extension does not matter. In one of them write regular text, in the other write valid python or shell code such as "from datetime import datetime" or "#!/bin/bash" When double clicked the regular text file will open in the default text editor, but the code opens in the browser.

echo "from datetime import datetime" > file1
echo "lorem ipsum dolor sit amet" > file2

image

Expected behavior: Both files open on the default text editor instead of the default browser

Other notes: I am on fedora 40 workstation. This is only partly reproducible with python scripts, a text file containing from datetime import datetime always opens in firefox, but a text file containing import numpy as np always opens in cosmic edit. Shell scripts always open in firefox presumably because they all begin with #!/bin/bash Not sure about other languages because I have not tried them. Empty files also open in firefox

jackpot51 commented 1 week ago

Can you determine which mime types are detected for these files?

JoaoDelille commented 1 week ago

Can you determine which mime types are detected for these files?

As it turns out, plaintext opens in the editor, while what is detected as Python opens in Firefox. image

As before, file extension does not matter.

JoaoDelille commented 1 week ago

I should add that cosmic files does NOT match what the mime type reports:

image

19MisterX98 commented 2 days ago

I have an html file and it is opened by brave by default. It should open in firefox since that is my default browser. I suspect that the code simply picks the first entry in the "open with" menu when clicking the "open" button. The "open with" menu is sorted alphabetically. Uninstalling brave leads it to open calibre when clicking the file which also corresponds to the now first entry in the "open with" menu.

JoaoDelille commented 2 days ago

@19MisterX98 That sounds like a different issue from mine. The scripts im talking about don't even show firefox as an option: image Maybe open a new issue for that bug

19MisterX98 commented 2 days ago

Kk

Edit: It somehow fixed itself and detects firefox as the default now