Add support for passing cursor information via URL parameters when running kioclient exec.
ClosedPublic

Authored by arrowd on Jan 16 2019, 1:59 PM.

Details

Summary

Second part of fix for a BUG 398998 ( https://bugs.kde.org/show_bug.cgi?id=398998 ).
Kate changes are in D18099.

Test Plan

Printed resulted URL with qDebug().

Diff Detail

Repository
R126 KDE CLI Utilities
Branch
cursor
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 7178
Build 7196: arc lint + arc unit
arrowd created this revision.Jan 16 2019, 1:59 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 16 2019, 1:59 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
arrowd requested review of this revision.Jan 16 2019, 1:59 PM

Ping? Any chance to get this into 5.15?

Pingy-ping, bumpy-bump.

cullmann added a subscriber: cullmann.

Perhaps Kai has some opinion.

Monthly bump.

apol added a subscriber: apol.Mar 25 2019, 11:55 AM

Overall this makes sense to me, this assumes though that there will never be a file ending with :digit, is that something we can live with?

kioclient/urlinfo.h
68

capturedRef, no need to instantiate the QString to destroy again.

arrowd added a comment.EditedMar 25 2019, 1:57 PM
In D18296#437985, @apol wrote:

Overall this makes sense to me, this assumes though that there will never be a file ending with :digit, is that something we can live with?

Judging from

UrlInfo(QString path)
    : line(0), column(0)
{
    /**
     * first try: just check if the path is an existing file
     */
    if (QFile::exists(path)) {
        /**
         * create absolute file path, we will e.g. pass this over dbus to other processes
         * and then we are done, no cursor can be detected here!
         */
        url = QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
        return;
    }

such files can still be opened, they just can't receive cursor information.

arrowd updated this revision to Diff 54774.Mar 25 2019, 2:01 PM
arrowd marked an inline comment as done.

Address comments.

cullmann resigned from this revision.Mar 31 2019, 10:44 AM
arrowd added a comment.Apr 5 2019, 8:45 AM

Can I finally push this?

Is it really necessary to copy urlinfo.h here? Wouldn't be enough to just create a static function and put the URL parsing logic there?

kioclient/urlinfo.h
46–53

Why doesn't it parse the URL if the file already exists?

arrowd added a comment.Apr 6 2019, 5:32 PM

Is it really necessary to copy urlinfo.h here? Wouldn't be enough to just create a static function and put the URL parsing logic there?

I just copied this from Kate project. KDevelop also done this.

arrowd added inline comments.Apr 6 2019, 5:33 PM
kioclient/urlinfo.h
46–53

If the file is named foo:123, it refuses to search for cursor infomation and just open it.

dfaure requested changes to this revision.Apr 8 2019, 8:05 AM

Is the makeURL function still used, or should it be removed now?

kioclient/urlinfo.h
40

const QString &

And what if it's a URL? At this point this string is pathOrUrl.

78

I'm not sure about AssumeLocalFile, in the context of kde-open.
This is about opening existing files, not creating new files.
So it should be removed.

This revision now requires changes to proceed.Apr 8 2019, 8:05 AM
arrowd added a comment.Apr 9 2019, 5:21 AM

Is the makeURL function still used, or should it be removed now?

Yep, it is still used in a bunch of other places.

kioclient/urlinfo.h
40

const QString &

There is path.chop(match.capturedLength());, which requires non-const QString.

And what if it's a URL? At this point this string is pathOrUrl.

Well, if (QFile::exists(path)) will return false in this case, and url would get populated by url = QUrl::fromUserInput(). What's wrong with that?

78

It is not about creating missing files, but reaction to user typos. If I try to open fiel.txt instead of a file.txt, I want to get a "no such file or directory error message" instead of popping browser trying to open "http://fiel.txt".

dfaure added inline comments.Apr 9 2019, 10:14 PM
kioclient/urlinfo.h
40

I'm suggesting to at least rename the argument to pathOrUrl to be clear about what it contains.
A path is not a URL.

I see, about the chop(). It is customary, however, to make a local copy where needed. For instance this will avoid the copy when the file exists (and we get to the early return, before the copy that you'll need only further down).

78

But then you can't do kde-open5 www.google.fr anymore, right?

I see what you mean with typo handling, but there is no perfect solution. Either we treat typos as URLs (but it means we also treat actual URLs as such), or we treat everything non-existing as a local file (breaking any use of short URLs). The latter is OK for kwrite, but not for the more general purpose kioclient / kde-open5.

arrowd updated this revision to Diff 55879.Apr 10 2019, 6:52 AM
arrowd marked 5 inline comments as done.

Address comments.

arrowd added inline comments.Apr 10 2019, 6:53 AM
kioclient/urlinfo.h
78

But then you can't do kde-open5 www.google.fr anymore, right?

Ah, right. Ok, then.

dfaure accepted this revision.Apr 11 2019, 6:35 AM
dfaure added inline comments.
kioclient/urlinfo.h
77

remove old comment

This revision is now accepted and ready to land.Apr 11 2019, 6:35 AM
This revision was automatically updated to reflect the committed changes.
arrowd marked an inline comment as done.Apr 11 2019, 7:47 AM