Pasting a path extracted from a repo web link on cgit, github, gitlab, or lxr
to Quick Open currently needs manual editing of the line number notion.
This patch allows to open them directly.
Details
Diff Detail
- Repository
- R33 KDevPlatform
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Please add tests in util/tests/test_texteditorhelpers.cpp.
util/texteditorhelpers.cpp | ||
---|---|---|
61 ↗ | (On Diff #10118) | Code looks a bit too branchy. Maybe it'd make more sense if you'd just use on instance of QRegularExpressionMatch? auto match = pattern.match(input); if (!match.hasMatch()) { match2 = pattern.match(input); } // ... as before For pattern2 match.captured(2).toInt() will always return 0, which should be handled fine by the original code. |
util/texteditorhelpers.cpp | ||
---|---|---|
61 ↗ | (On Diff #10118) | Meant match = pattern2.match(input); in line 3 of course... |
Note: I'm wondering whether we should try to upstream this one way or the other to ktexteditor.git -- this feature (extract line + column numbers) from path-like strings is used in many places in both Kate & KTextEditor.
Another place: command-line handling, e.g. both kate and kdevelop accepted: kdevelop /path/to/file.cpp:100. The code which is currently handling this is https://github.com/KDE/kate/blob/master/urlinfo.h -- and I shamelessly copied that to kdevelop.git, too ;)
@kwrite-devel Please check whether a function such as this would make sense in ktexteditor.git:
struct UrlCursor { QUrl url; Cursor cursor; } /// Parse @p pathLike input and extract the url part and the line/column information /// Example: /path/to/file.cpp:111, /path/to/file.cpp#L111 KTextEditor::UrlCursor KTextEditorHelpers::extractCursor(const QString& pathLike);
This functionality is duplicated in at least kate + kdevelop, probaby other places, too.
Not sure where to put it and whether ktexteditor.git would be the right place to start with though.