forked from qt-creator/qt-creator
Terminal: Linkify git commits
Allows the user to Ctrl(Cmd)+Click "version like" text (e.g. text that only contains 0-9 and a-f) and starts a "vcsDescribe" if a version control can be found for the current directory. Fixes: QTCREATORBUG-29213 Change-Id: I462092b58bf595a6968f4765f83a207506f0cf87 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -14,8 +14,9 @@
|
|||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
#include <coreplugin/find/textfindconstants.h>
|
#include <coreplugin/find/textfindconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/locator/locatorconstants.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/async.h>
|
#include <utils/async.h>
|
||||||
@@ -418,6 +419,13 @@ std::optional<TerminalSolution::TerminalView::Link> TerminalWidget::toLink(const
|
|||||||
return Link{link.targetFilePath.toString(), link.targetLine, link.targetColumn};
|
return Link{link.targetFilePath.toString(), link.targetLine, link.targetColumn};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!m_cwd.isEmpty() && Utils::allOf(text, [](QChar c) {
|
||||||
|
c = c.toLower();
|
||||||
|
return c.isDigit() || (c >= 'a' && c <= 'f');
|
||||||
|
})) {
|
||||||
|
Link link{QString("vcs:///%1").arg(text)};
|
||||||
|
return link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -489,6 +497,18 @@ void TerminalWidget::selectionChanged(const std::optional<Selection> &newSelecti
|
|||||||
|
|
||||||
void TerminalWidget::linkActivated(const Link &link)
|
void TerminalWidget::linkActivated(const Link &link)
|
||||||
{
|
{
|
||||||
|
if (link.text.startsWith("vcs:///")) {
|
||||||
|
QString reference = link.text.mid(7);
|
||||||
|
IVersionControl *vcs = VcsManager::findVersionControlForDirectory(m_cwd);
|
||||||
|
|
||||||
|
if (vcs) {
|
||||||
|
vcs->vcsDescribe(m_cwd, reference);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FilePath filePath = FilePath::fromUserInput(link.text);
|
FilePath filePath = FilePath::fromUserInput(link.text);
|
||||||
|
|
||||||
if (filePath.scheme().toString().startsWith("http")) {
|
if (filePath.scheme().toString().startsWith("http")) {
|
||||||
|
Reference in New Issue
Block a user