forked from qt-creator/qt-creator
LSP: Fix lagging behind "documentHighlight"
We highlight the current symbol on cursor changes (="documentHighlight"), but when the contents change the text editor widget first informs us about the cursor change, then the content change. This resulted in the highlighting being done on the old content. Delay the symbol highlight by a short amount of time, so it always operates on the new content. Change-Id: Ic24b2a853697c588ae73b102868e8f74e4437606 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace LanguageServerProtocol;
|
||||
using namespace Utils;
|
||||
@@ -150,9 +151,13 @@ void BaseClient::openDocument(Core::IDocument *document)
|
||||
if (textDocument) {
|
||||
textDocument->setCompletionAssistProvider(new LanguageClientCompletionAssistProvider(this));
|
||||
if (BaseTextEditor *editor = BaseTextEditor::textEditorForDocument(textDocument)) {
|
||||
if (TextEditorWidget *widget = editor->editorWidget()) {
|
||||
if (QPointer<TextEditorWidget> widget = editor->editorWidget()) {
|
||||
connect(widget, &TextEditorWidget::cursorPositionChanged, this, [this, widget](){
|
||||
cursorPositionChanged(widget);
|
||||
// TODO This would better be a compressing timer
|
||||
QTimer::singleShot(50, this, [this, widget]() {
|
||||
if (widget)
|
||||
cursorPositionChanged(widget);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user