CMakeEditor: Add fallback help ID

Like we do for the BaseTextEditor.
This allows users to get context help also for items that are not
"commands", like various variables that have a meaning for CMake.

Change-Id: Ie1af61bdffdeecb406b1dc7e6127000c17ea5a8e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2019-08-05 13:40:36 +02:00
parent 22092ee4e6
commit 42b8a22840

View File

@@ -45,6 +45,7 @@
#include <texteditor/texteditorconstants.h>
#include <utils/qtcassert.h>
#include <utils/textutils.h>
#include <QFileInfo>
#include <QTextBlock>
@@ -71,7 +72,7 @@ void CMakeEditor::contextHelp(const HelpCallback &callback) const
break;
chr = characterAt(pos);
if (chr == QLatin1Char('(')) {
callback({});
BaseTextEditor::contextHelp(callback);
return;
}
} while (chr.unicode() != QChar::ParagraphSeparator);
@@ -97,12 +98,13 @@ void CMakeEditor::contextHelp(const HelpCallback &callback) const
// Not a command
if (chr != QLatin1Char('(')) {
callback({});
BaseTextEditor::contextHelp(callback);
return;
}
const QString id = "command/" + textAt(begin, end - begin).toLower();
callback(id);
callback(
{{id, Utils::Text::wordUnderCursor(editorWidget()->textCursor())}, {}, HelpItem::Unknown});
}
//