Commit f69ac7ac authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: send didSave notification if so requested

parent f932b667
Pipeline #109990 passed with stage
in 4 minutes and 22 seconds
......@@ -1255,7 +1255,8 @@ private:
{QStringLiteral("documentSymbol"), QJsonObject{{QStringLiteral("hierarchicalDocumentSymbolSupport"), true}} },
{QStringLiteral("publishDiagnostics"), QJsonObject{{QStringLiteral("relatedInformation"), true}}},
{QStringLiteral("codeAction"), codeAction},
{QStringLiteral("semanticTokens"), semanticTokens}
{QStringLiteral("semanticTokens"), semanticTokens},
{QStringLiteral("synchronization"), QJsonObject{{QStringLiteral("didSave"), true}}},
},
},
{QStringLiteral("window"),
......@@ -1475,7 +1476,9 @@ public:
void didSave(const QUrl &document, const QString &text)
{
auto params = textDocumentParams(document);
params[QStringLiteral("text")] = text;
if (!text.isNull()) {
params[QStringLiteral("text")] = text;
}
send(init_request(QStringLiteral("textDocument/didSave"), params));
}
......
......@@ -833,6 +833,7 @@ private:
connect(doc, &KTextEditor::Document::aboutToClose, this, &self_type::untrack, Qt::UniqueConnection);
connect(doc, &KTextEditor::Document::destroyed, this, &self_type::untrack, Qt::UniqueConnection);
connect(doc, &KTextEditor::Document::textChanged, this, &self_type::onTextChanged, Qt::UniqueConnection);
connect(doc, &KTextEditor::Document::documentSavedOrUploaded, this, &self_type::onDocumentSaved, Qt::UniqueConnection);
// in case of incremental change
connect(doc, &KTextEditor::Document::textInserted, this, &self_type::onTextInserted, Qt::UniqueConnection);
connect(doc, &KTextEditor::Document::textRemoved, this, &self_type::onTextRemoved, Qt::UniqueConnection);
......@@ -976,6 +977,20 @@ private:
}
}
void onDocumentSaved(KTextEditor::Document *doc, bool saveAs)
{
if (!saveAs) {
auto it = m_docs.find(doc);
if (it != m_docs.end() && it->server) {
auto server = it->server;
const auto &saveOptions = server->capabilities().textDocumentSync.save;
if (saveOptions) {
server->didSave(doc->url(), saveOptions->includeText ? doc->text() : QString());
}
}
}
}
void onMessage(bool isLog, const LSPLogMessageParams &params)
{
// determine server description
......
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