Kate/KWrite support "file.cpp:123:456" notion to open a text file at the specified line/row position. I use "kioclient exec" extensively to open text files and it would be super-neat to be able to open where compiler reported a error. I poked around code a bit and it boiled down to making KRun accept plain QString instead of QUrl, because the latter can't hold cursor information. I'm ready to implement this, but first wanted to consult code owners. For reference, Kate/KWrite use UrlInfo helper class that converts QString to QUrl with good old QUrl::fromUserInput, but additionaly chops and saves ":123:456" part at the end.
I'd say best way to deal with it would be to use url semantics (e.g. file.cpp?l=23). Either way, this needs to be decided by kate maintainers.
(In reply to Aleix Pol from comment #1) > I'd say best way to deal with it would be to use url semantics (e.g. > file.cpp?l=23). Either way, this needs to be decided by kate maintainers. This is less comfortable to type and as I said, the main idea is to be able to copy-paste error line produced by the compiler, like: /absolute/path/to/foo.cpp:123:1: Couldn't find #include <foo.h>
How about this: We add KRun::setCursorInformation(int,int) method and in KRun::runApplicationImpl() or whatever actually runs the program do if(serviceSupportsPassingCursorInfo()) args << "--line " << line << "--column" << column; where bool serviceSupportsPassingCursorInfo() { return service.name() == "KWrite" || service.name() == "Kate; } Looks pretty clean and non-invasive to me.
Moving to Kate for now.
(In reply to Gleb Popov from comment #2) > (In reply to Aleix Pol from comment #1) > > I'd say best way to deal with it would be to use url semantics (e.g. > > file.cpp?l=23). Either way, this needs to be decided by kate maintainers. > > This is less comfortable to type and as I said, the main idea is to be able > to copy-paste error line produced by the compiler, like: > > /absolute/path/to/foo.cpp:123:1: > Couldn't find #include <foo.h> What if kioclient converts from "foo.cpp:123:1" to url parameters? This way you can just copy-paste the thing and the patch in KIO would be less invasive (no need to add/change the KRun API).
Actually, if Kate adds support for row/column as URL parameters, we probably wouldn't need to patch KRun at all.
(In reply to Elvis Angelaccio from comment #6) > Actually, if Kate adds support for row/column as URL parameters, we probably > wouldn't need to patch KRun at all. Sounds OK, I'll try implementing it.
Git commit 1fa3a0e85e7146a7a3535980aadda6ebbab11ee6 by Gleb Popov. Committed on 15/01/2019 at 11:16. Pushed by arrowdodger into branch 'master'. Add ability to get cursor data from URL query arguments, like file://foo.txt?line=123&column=456 Summary: CCBUG: 398998 Test Plan: Opening a file with such URL works in both KWrite and Kate. Reviewers: #kate Subscribers: kwrite-devel Tags: #kate Differential Revision: https://phabricator.kde.org/D18099 M +15 -0 kate/kateapp.cpp M +16 -0 kwrite/main.cpp https://commits.kde.org/kate/1fa3a0e85e7146a7a3535980aadda6ebbab11ee6
Git commit 8072a6acf221b8b609a781290ee2870ca2eea3dd by Gleb Popov. Committed on 11/04/2019 at 07:41. Pushed by arrowdodger into branch 'master'. Add support for passing cursor information via URL parameters when running kioclient exec. 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()`. Reviewers: #plasma, #ktexteditor, broulik, cullmann, #frameworks, pino, cfeck, dfaure, elvisangelaccio Reviewed By: dfaure Subscribers: apol, cullmann, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D18296 M +16 -5 kioclient/kioclient.cpp M +1 -2 kioclient/kioclient.h A +108 -0 kioclient/urlinfo.h [License: LGPL] https://commits.kde.org/kde-cli-tools/8072a6acf221b8b609a781290ee2870ca2eea3dd
Please either revert or fix this patch, it is BREAKING OTHER APPLICATIONS, see https://bugs.kde.org/show_bug.cgi?id=408632
Since it was me who made this change, I'll look at it ASAP. Sorry for missing initial bug report.
Fixed with https://phabricator.kde.org/D22525