From a35fd423647e4c240e1ba8905e215e3e3dd681bc Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 30 May 2023 13:48:01 +0200 Subject: [PATCH] Copilot: position copilot tooltip above cursor rect Change-Id: I37c6572000231334b90f38a2b37f5983c80174a5 Reviewed-by: Marcus Tillmanns Reviewed-by: --- src/plugins/copilot/copilothoverhandler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/copilot/copilothoverhandler.cpp b/src/plugins/copilot/copilothoverhandler.cpp index b252cedc77d..bf4d3ece104 100644 --- a/src/plugins/copilot/copilothoverhandler.cpp +++ b/src/plugins/copilot/copilothoverhandler.cpp @@ -147,8 +147,12 @@ void CopilotHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const Q auto tooltipWidget = new CopilotCompletionToolTip(suggestion->completions(), suggestion->currentCompletion(), editorWidget); - const qreal deltay = 2 * editorWidget->textDocument()->fontSettings().lineSpacing(); - ToolTip::show(point - QPoint{0, int(deltay)}, tooltipWidget, editorWidget); + + const QRect cursorRect = editorWidget->cursorRect(editorWidget->textCursor()); + QPoint pos = editorWidget->viewport()->mapToGlobal(cursorRect.topLeft()) + - Utils::ToolTip::offsetFromPosition(); + pos.ry() -= tooltipWidget->sizeHint().height(); + ToolTip::show(pos, tooltipWidget, editorWidget); } } // namespace Copilot::Internal