forked from qt-creator/qt-creator
TextEditor: Fix wrong tooltip when split mode is used
It was possible to get a tooltip with cached text from other editor area Fixes: QTCREATORBUG-28571 Change-Id: I4250856e6c165eed70ddb4a6c888e16b4a6b045d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -19,6 +19,11 @@ void BaseHoverHandler::showToolTip(TextEditorWidget *widget, const QPoint &point
|
||||
operateTooltip(widget, point);
|
||||
}
|
||||
|
||||
bool BaseHoverHandler::lastHelpItemAppliesTo(const TextEditorWidget *widget) const
|
||||
{
|
||||
return m_lastWidget == widget;
|
||||
}
|
||||
|
||||
void BaseHoverHandler::checkPriority(TextEditorWidget *widget,
|
||||
int pos,
|
||||
ReportPriority report)
|
||||
@@ -106,8 +111,12 @@ void BaseHoverHandler::process(TextEditorWidget *widget, int pos, ReportPriority
|
||||
m_toolTip.clear();
|
||||
m_priority = -1;
|
||||
m_lastHelpItemIdentified = Core::HelpItem();
|
||||
m_lastWidget = nullptr;
|
||||
|
||||
identifyMatch(widget, pos, report);
|
||||
identifyMatch(widget, pos, [this, widget, report](int priority) {
|
||||
m_lastWidget = widget;
|
||||
report(priority);
|
||||
});
|
||||
}
|
||||
|
||||
void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, ReportPriority report)
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
virtual void abort() {} // Implement for asynchronous priority reporter
|
||||
|
||||
void showToolTip(TextEditorWidget *widget, const QPoint &point);
|
||||
bool lastHelpItemAppliesTo(const TextEditorWidget *widget) const;
|
||||
|
||||
protected:
|
||||
enum {
|
||||
@@ -68,6 +69,7 @@ private:
|
||||
Core::HelpItem m_lastHelpItemIdentified;
|
||||
int m_priority = -1;
|
||||
bool m_isContextHelpRequest = false;
|
||||
TextEditorWidget *m_lastWidget = nullptr;
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
// Does the last handler still applies?
|
||||
const int documentRevision = textCursor.document()->revision();
|
||||
const int position = Text::wordStartCursor(textCursor).position();
|
||||
if (m_lastHandlerInfo.applies(documentRevision, position)) {
|
||||
if (m_lastHandlerInfo.applies(documentRevision, position, m_widget)) {
|
||||
callback(m_widget, m_lastHandlerInfo.handler, position);
|
||||
return;
|
||||
}
|
||||
@@ -399,9 +399,10 @@ private:
|
||||
, cursorPosition(cursorPosition)
|
||||
{}
|
||||
|
||||
bool applies(int documentRevision, int cursorPosition) const
|
||||
bool applies(int documentRevision, int cursorPosition, TextEditorWidget *widget) const
|
||||
{
|
||||
return handler
|
||||
&& handler->lastHelpItemAppliesTo(widget)
|
||||
&& documentRevision == this->documentRevision
|
||||
&& cursorPosition == this->cursorPosition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user