forked from qt-creator/qt-creator
Editor: Validate trigger from snippets xml
Fixes: QTCREATORBUG-24415 Change-Id: Ic99355220bf1948af8a17d6ce017924eba3fc3ba Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "snippet.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/templateengine.h>
|
||||
|
||||
#include <QTextDocument>
|
||||
@@ -105,6 +106,13 @@ const QString &Snippet::trigger() const
|
||||
return m_trigger;
|
||||
}
|
||||
|
||||
bool Snippet::isValidTrigger(const QString &trigger)
|
||||
{
|
||||
if (trigger.isEmpty() || trigger.at(0).isNumber())
|
||||
return false;
|
||||
return Utils::allOf(trigger, [](const QChar &c) { return c.isLetterOrNumber() || c == '_'; });
|
||||
}
|
||||
|
||||
void Snippet::setContent(const QString &content)
|
||||
{
|
||||
m_content = content;
|
||||
|
||||
Reference in New Issue
Block a user