ClangCodeModel: Work around clangd cursor issue

If the cursor is right before the "." in a member access expression,
clangd interprets it as belonging to the member instead of the base
expression, which leads to unexpected behavior.
Work around this by sending a cursor position one to the left of the
real one to clangd in such cases.

Change-Id: I429ee9189760ccb02d231acfcb94ab6cfde3cd8d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-12-02 13:18:02 +01:00
parent 0f9aa307a3
commit 825c9ea64f
4 changed files with 75 additions and 14 deletions

View File

@@ -102,6 +102,8 @@ private:
void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams &params) override;
void handleDocumentOpened(TextEditor::TextDocument *doc) override;
void handleDocumentClosed(TextEditor::TextDocument *doc) override;
QTextCursor adjustedCursorForHighlighting(const QTextCursor &cursor,
TextEditor::TextDocument *doc) override;
const CustomInspectorTabs createCustomInspectorTabs() override;
class Private;