Commit b0129eea authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

LSP: Avoid triggering signature help all the time

In some cases it can lead to really weird results.

BUG: 460113
parent 99e8066a
Pipeline #245297 passed with stage
in 20 minutes and 50 seconds
......@@ -298,6 +298,10 @@ public:
qCInfo(LSPCLIENT) << "should start " << userInsertion << insertedText;
if (!userInsertion || !m_server || insertedText.isEmpty()) {
if (!insertedText.isEmpty() && m_triggersSignature.contains(insertedText.back())) {
m_triggerSignature = true;
return true;
}
return false;
}
......@@ -321,6 +325,20 @@ public:
qCInfo(LSPCLIENT) << "completion invoked" << m_server;
if (it == UserInvocation && range.isEmpty() && m_signatureHelp) {
// If this is a user invocation (ctrl-space), check the last non-space char for sig help trigger
QChar c;
int i = range.start().column() - 1;
int ln = range.start().line();
for (; i >= 0; --i) {
c = view->document()->characterAt(KTextEditor::Cursor(ln, i));
if (!c.isSpace()) {
break;
}
}
m_triggerSignature = m_triggersSignature.contains(c);
}
// maybe use WaitForReset ??
// but more complex and already looks good anyway
auto handler = [this](const QList<LSPCompletionItem> &completion) {
......@@ -377,10 +395,10 @@ public:
auto position = view->cursorPosition();
auto cursor = qMax(range.start(), qMin(range.end(), position));
m_manager->update(document, false);
if (!m_triggerSignature) {
m_handle = m_server->documentCompletion(document->url(), {cursor.line(), cursor.column()}, this, handler);
}
if (m_signatureHelp) {
m_handle = m_server->documentCompletion(document->url(), {cursor.line(), cursor.column()}, this, handler);
if (m_signatureHelp && m_triggerSignature) {
m_handleSig = m_server->signatureHelp(document->url(), {cursor.line(), cursor.column()}, this, sigHandler);
}
}
......
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