Commit 996995cf authored by Fabian Kosmale's avatar Fabian Kosmale Committed by Christoph Cullmann
Browse files

lspclient: Enable copying diagnostics

This adds a custom menu entry to the diagnostics' context menu, which
simply copies the diagnostic message to the clipboard.

The targeted use cases are to ease the "make mistake → search for
mistake → find (wrong) solution online" workflow, as well as being able
to copy wrong warnings when reporting bugs against a LSP server
implementation.
parent f16b2eb2
......@@ -38,6 +38,7 @@
#include <QAction>
#include <QApplication>
#include <QClipboard>
#include <QDateTime>
#include <QFileInfo>
#include <QHBoxLayout>
......@@ -2322,9 +2323,13 @@ public:
auto item = m_diagnosticsModel->itemFromIndex(index);
auto diagItem = dynamic_cast<DiagnosticItem *>(item);
auto docDiagItem = dynamic_cast<DocumentDiagnosticItem *>(item);
if (diagItem) {
auto diagText = index.data().toString();
menu->addAction(QIcon::fromTheme(QLatin1String("edit-copy")), i18n("Copy Diagnostic to Clipboard"), [diagText]() {
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(diagText);
});
menu->addSeparator();
auto parent = index.parent();
docDiagItem = dynamic_cast<DocumentDiagnosticItem *>(m_diagnosticsModel->itemFromIndex(parent));
// track validity of raw pointer
......
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