Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ef15473f authored by Kåre Särs's avatar Kåre Särs

Add optional file search directory to the build plugin

Sometimes the build system prints out relative paths that are not
relative to the current work directory. Adding a search path makes it
possible for the plugin to find and open the correct file.
parent 4c34adcd
......@@ -111,7 +111,7 @@ QWidget *TargetHtmlDelegate::createEditor(QWidget *dparent, const QStyleOptionVi
UrlInserter *requester = new UrlInserter(parent()->property("docUrl").toUrl(), dparent);
requester->setReplace(true);
editor = requester;
editor->setToolTip(i18n("Leave empty to use the directory of the current document."));
editor->setToolTip(i18n("Leave empty to use the directory of the current document.\nAdd search directories by adding paths separated by ';'"));
} else if (index.column() == 1) {
UrlInserter *urlEditor = new UrlInserter(parent()->property("docUrl").toUrl(), dparent);
editor = urlEditor;
......
......@@ -464,7 +464,7 @@ void KateBuildView::slotErrorSelected(QTreeWidgetItem *item)
// Check if the file exists
if (!QFileInfo::exists(filename)) {
displayMessage(xi18nc("@info", "<title>Could not open file:</title><nl/>%1", filename), KTextEditor::Message::Error);
displayMessage(xi18nc("@info", "<title>Could not open file:</title><nl/>%1<br>Try adding a search path to the working directory in the Target Settings", filename), KTextEditor::Message::Error);
return;
}
......@@ -858,7 +858,8 @@ bool KateBuildView::buildCurrentTarget()
QString buildCmd = m_targetsUi->targetsModel.command(ind);
QString cmdName = m_targetsUi->targetsModel.cmdName(ind);
QString workDir = m_targetsUi->targetsModel.workDir(ind);
m_searchPaths = m_targetsUi->targetsModel.workDir(ind).split(QLatin1Char(';'));
QString workDir = m_searchPaths.isEmpty() ? QString() : m_searchPaths.first();
QString targetSet = m_targetsUi->targetsModel.targetName(ind);
QString dir = workDir;
......@@ -1093,6 +1094,15 @@ void KateBuildView::processLine(const QString &line)
filename = m_make_dir + QLatin1Char('/') + filename;
}
// If we still do not have a file name try the extra search paths
int i = 1;
while (!QFile::exists(filename) && i < m_searchPaths.size()) {
if (QFile::exists(m_searchPaths[i] + QLatin1Char('/') + filename)) {
filename = m_searchPaths[i] + QLatin1Char('/') + filename;
}
i++;
}
// get canonical path, if possible, to avoid duplicated opened files
auto canonicalFilePath(QFileInfo(filename).canonicalFilePath());
if (!canonicalFilePath.isEmpty()) {
......
......@@ -146,6 +146,7 @@ private:
int m_displayModeBeforeBuild;
QString m_make_dir;
QStack<QString> m_make_dir_stack;
QStringList m_searchPaths;
QRegularExpression m_filenameDetector;
QRegularExpression m_filenameDetectorIcpc;
bool m_filenameDetectorGccWorked;
......
Markdown is supported
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