Bug 431496 - Konsole commit 5cb2121751569d8fb1e478b10e5980be4abeaa9b: all files open in defined text editor
Summary: Konsole commit 5cb2121751569d8fb1e478b10e5980be4abeaa9b: all files open in de...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-12 13:14 UTC by rcorreia31
Modified: 2021-01-15 07:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rcorreia31 2021-01-12 13:14:49 UTC
SUMMARY
Before commit 5cb2121751569d8fb1e478b10e5980be4abeaa9b, using Control-click on a file used to open it in the configured application.
I.E.: .html in Firefox, .pdf in Okular, ...
Now all the files are opened in Kate (configured text editor for konsole), no matter what their extension/type is.
Checked with bisect.

STEPS TO REPRODUCE
1. Start konsole
2. ls
2. Click on a .pdf or .html

OBSERVED RESULT
File is opened with Kate (default Konsole editor). It should be opened with the right application based on its type.

EXPECTED RESULT
As before this commit: open the file in the right application.
I.E.: open pdf with Okular, if Okular is the defined application for pdf.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.20.2
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.1
Comment 1 Ahmad Samir 2021-01-12 15:53:38 UTC
For now as a workaround, you can get the old behaviour back by setting the "Text editor command" to "Custom" and leaving it empty (you can edit the the custom entry); it's in "Edit current profile" > Mouse > Miscellaneous.
Comment 2 rcorreia31 2021-01-12 15:58:35 UTC
Thanks, this workaround works great.
Comment 3 Bug Janitor Service 2021-01-12 16:35:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/326
Comment 4 Ahmad Samir 2021-01-13 01:53:08 UTC
Git commit 43c14e980141d66b5c21b6bdee12c67d3c4bf3f3 by Ahmad Samir.
Committed on 12/01/2021 at 16:27.
Pushed by hindenburg into branch 'master'.

FileFilterHotspot: check the mime type before opening with text editor

When activating a file filter hot spot, everything got opened with the text
editor specified in the profile settings, which is wrong e.g. with pdf or
png files. Check the mime type of the file path, based only on the extension
so as to keep things fast.

Also rename openWithSysDefaultEditor() to openWithSysDefaultApp(), which is
more accurate.

M  +12   -4    src/filterHotSpots/FileFilterHotspot.cpp
M  +1    -1    src/filterHotSpots/FileFilterHotspot.h

https://invent.kde.org/utilities/konsole/commit/43c14e980141d66b5c21b6bdee12c67d3c4bf3f3
Comment 5 rcorreia31 2021-01-13 15:04:43 UTC
Thanks for fix.
I still have an issue with the latest commit: .htm and .html files are opened in the editor and not in the defined browser.
If I click in an html file within dolphin or krusader, the browser is opened has expected.

Here the tests I did.
For a pdf:
. mimeType.inherits(QStringLiteral("text/plain") = 0
. mimeType.name() = application/pdf
For .htm ot .html:
. mimeType.inherits(QStringLiteral("text/plain") = 1
. mimeType.name() = text/html
For a .txt file :
. mimeType.inherits(QStringLiteral("text/plain") = 1
. mimeType.name() = text/plain

So for both .txt and .html, mimeType.inherits(QStringLiteral("text/plain") returns 1.
It might be expected but it prevents the browser from being opened.

For the sake of trying, I changed this test:
  if (!mimeType.inherits(QStringLiteral("text/plain")) || mimeType.name()==QStringLiteral("text/html") ) {
Now I have the expected behavior.
As I know almost nothing about Qt C++ development, there is surely a better way of handling this.
Comment 6 Ahmad Samir 2021-01-13 15:15:34 UTC
We are in the realm of colliding use-cases, on the one hand an .html text/html, inherits text/plain, so if a user grep's for a string in a dir that contains .html files with instances of that string, he'd get output like:
foo.html:20

now, if we exclude the text/html mime type the user will have the file opened in web browser, and if we leave it, then the file will be opened by the specified text editor at line 20.

Experimenting with this some more, it looks like you can right click a .html file and select "open with <whatever web browser>" and ctrl + click to open it in a text editor... which admittedly could be confusing.
Comment 7 rcorreia31 2021-01-15 07:43:04 UTC
Thanks for the explanation.
I did not know that clicking on a "file:line" opens it at the right position.
Very useful indeed.
So it perfectly make sense to open the html in the editor as well.