LanguageClient: Take quickfix range from cursor selection

We must respect the selection the user made, otherwise code actions
might not work correctly.

Change-Id: I39142047f90f3d7c85aefbfa960e59d413e4be38
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-05-13 15:52:01 +02:00
parent 1e25be0cfd
commit e2890aa1ff

View File

@@ -73,12 +73,13 @@ IAssistProposal *LanguageClientQuickFixAssistProcessor::perform(const AssistInte
CodeActionParams params;
params.setContext({});
QTextCursor cursor(interface->textDocument());
cursor.setPosition(interface->position());
if (cursor.atBlockEnd() || cursor.atBlockStart())
cursor.select(QTextCursor::LineUnderCursor);
else
cursor.select(QTextCursor::WordUnderCursor);
QTextCursor cursor = interface->cursor();
if (!cursor.hasSelection()) {
if (cursor.atBlockEnd() || cursor.atBlockStart())
cursor.select(QTextCursor::LineUnderCursor);
else
cursor.select(QTextCursor::WordUnderCursor);
}
if (!cursor.hasSelection())
cursor.select(QTextCursor::LineUnderCursor);
Range range(cursor);