Commit 978b9f7e authored by Eric Armbruster's avatar Eric Armbruster 🍁 Committed by Christoph Cullmann
Browse files

Ensure path is shortened correctly

This is to avoid a scenario described by @odeda:

Given project based dir ~/doc and a file at ~/documents/foo.txt (a
different directory), wouldn't this code cause shortestPath() to return
"uments/foo.txt"? This would not be useful.
parent 7dcc41fd
Pipeline #236802 canceled with stage
in 12 minutes and 2 seconds
......@@ -1666,7 +1666,12 @@ public:
QObject *project = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin"));
if (project) {
return project->property("projectBaseDir").toString();
auto baseDir = project->property("projectBaseDir").toString();
if (!baseDir.endsWith(QLatin1Char('/'))) {
return baseDir + QLatin1Char('/');
return baseDir;
return {};
......@@ -1675,12 +1680,7 @@ public:
QString shortenPath(QString projectBaseDir, QString url)
if (!projectBaseDir.isEmpty() && url.startsWith(projectBaseDir)) {
QString res = url.mid(projectBaseDir.length());
if (res.startsWith(QLatin1Char('/'))) {
return res.mid(1);
return res;
return url.mid(projectBaseDir.length());
return url;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment