From c5b874dcf362785e9cab5f212417c48eb6f6c81e Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 7 Jan 2019 09:56:52 +0100 Subject: [PATCH] Clang: Show help with F1 even if there is a diagnostic ...at that particular location. For example, the code new QSignalMapper; produced a deprecated warning with Qt 5.12 and F1 led to "No documentation available" as the diagnostic was always prioritized. Task-number: QTCREATORBUG-21686 Change-Id: Icf03000fb6b9de04e467e758da6167018d154a21 Reviewed-by: Marco Bubke Reviewed-by: Ivan Donchevskii Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clanghoverhandler.cpp | 2 +- src/plugins/texteditor/basehoverhandler.cpp | 9 +++++++++ src/plugins/texteditor/basehoverhandler.h | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clanghoverhandler.cpp b/src/plugins/clangcodemodel/clanghoverhandler.cpp index 33754cfb6af..be598051701 100644 --- a/src/plugins/clangcodemodel/clanghoverhandler.cpp +++ b/src/plugins/clangcodemodel/clanghoverhandler.cpp @@ -114,7 +114,7 @@ void ClangHoverHandler::identifyMatch(TextEditorWidget *editorWidget, m_cursorPosition = -1; // Check for diagnostics (sync) - if (editorDocumentProcessorHasDiagnosticAt(editorWidget, pos)) { + if (!isContextHelpRequest() && editorDocumentProcessorHasDiagnosticAt(editorWidget, pos)) { qCDebug(hoverLog) << "Checking for diagnostic at" << pos; setPriority(Priority_Diagnostic); m_cursorPosition = pos; diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index b8ac2802802..157397ef2f8 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -73,6 +73,8 @@ void BaseHoverHandler::contextHelpId(TextEditorWidget *widget, int pos, const Core::IContext::HelpIdCallback &callback) { + m_isContextHelpRequest = true; + // If the tooltip is visible and there is a help match, this match is used to update // the help id. Otherwise, let the identification process happen. if (!Utils::ToolTip::isVisible() || !lastHelpItemIdentified().isValid()) { @@ -83,6 +85,8 @@ void BaseHoverHandler::contextHelpId(TextEditorWidget *widget, } else { propagateHelpId(widget, callback); } + + m_isContextHelpRequest = false; } void BaseHoverHandler::setToolTip(const QString &tooltip) @@ -105,6 +109,11 @@ const HelpItem &BaseHoverHandler::lastHelpItemIdentified() const return m_lastHelpItemIdentified; } +bool BaseHoverHandler::isContextHelpRequest() const +{ + return m_isContextHelpRequest; +} + void BaseHoverHandler::propagateHelpId(TextEditorWidget *widget, const Core::IContext::HelpIdCallback &callback) { diff --git a/src/plugins/texteditor/basehoverhandler.h b/src/plugins/texteditor/basehoverhandler.h index bc8d3e3e1d5..5e0187335a1 100644 --- a/src/plugins/texteditor/basehoverhandler.h +++ b/src/plugins/texteditor/basehoverhandler.h @@ -71,6 +71,8 @@ protected: void setLastHelpItemIdentified(const HelpItem &help); const HelpItem &lastHelpItemIdentified() const; + bool isContextHelpRequest() const; + void propagateHelpId(TextEditorWidget *widget, const Core::IContext::HelpIdCallback &callback); // identifyMatch() is required to report a priority by using the "report" callback. @@ -87,6 +89,7 @@ private: QString m_toolTip; HelpItem m_lastHelpItemIdentified; int m_priority = -1; + bool m_isContextHelpRequest = false; }; } // namespace TextEditor