forked from qt-creator/qt-creator
QmlDesigner: Do not escape "\" for unicode chars
Task-number: QTCREATORBUG-12616 Change-Id: If8cac8d35cb97f59e12d1609f808dd639f93f315 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
09b176040d
commit
f9f74566a7
@@ -273,6 +273,9 @@ QString QmlTextGenerator::escape(const QString &value)
|
|||||||
{
|
{
|
||||||
QString result = value;
|
QString result = value;
|
||||||
|
|
||||||
|
if (value.count() == 6 && value.startsWith("\\u")) //Do not dobule escape unicode chars
|
||||||
|
return result;
|
||||||
|
|
||||||
result.replace(QStringLiteral("\\"), QStringLiteral("\\\\"));
|
result.replace(QStringLiteral("\\"), QStringLiteral("\\\\"));
|
||||||
|
|
||||||
result.replace(QStringLiteral("\""), QStringLiteral("\\\""));
|
result.replace(QStringLiteral("\""), QStringLiteral("\\\""));
|
||||||
|
|||||||
@@ -993,6 +993,37 @@ void tst_TestCore::testRewriterChangeImports()
|
|||||||
QCOMPARE(model->imports().first(), Import::createLibraryImport("QtQuick", "1.1"));
|
QCOMPARE(model->imports().first(), Import::createLibraryImport("QtQuick", "1.1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_TestCore::testRewriterUnicodeChars()
|
||||||
|
{
|
||||||
|
const QLatin1String qmlString("\n"
|
||||||
|
"import QtQuick 2.1\n"
|
||||||
|
"\n"
|
||||||
|
"Text {\n"
|
||||||
|
" text: \"test\""
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
QPlainTextEdit textEdit;
|
||||||
|
textEdit.setPlainText(qmlString);
|
||||||
|
NotIndentingTextEditModifier modifier(&textEdit);
|
||||||
|
|
||||||
|
QScopedPointer<Model> model(Model::create("QtQuick.Rectangle"));
|
||||||
|
|
||||||
|
QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView(0, RewriterView::Amend));
|
||||||
|
testRewriterView->setTextModifier(&modifier);
|
||||||
|
model->attachView(testRewriterView.data());
|
||||||
|
|
||||||
|
QVERIFY(testRewriterView->errors().isEmpty());
|
||||||
|
|
||||||
|
ModelNode rootModelNode = testRewriterView->rootModelNode();
|
||||||
|
QVERIFY(rootModelNode.isValid());
|
||||||
|
|
||||||
|
rootModelNode.variantProperty("text").setValue("\\u2795");
|
||||||
|
|
||||||
|
const QLatin1String unicodeChar("\nimport QtQuick 2.1\n\nText {\n text: \"\\u2795\"}\n");
|
||||||
|
|
||||||
|
QCOMPARE(textEdit.toPlainText(), unicodeChar);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_TestCore::testRewriterForGradientMagic()
|
void tst_TestCore::testRewriterForGradientMagic()
|
||||||
{
|
{
|
||||||
const QLatin1String qmlString("\n"
|
const QLatin1String qmlString("\n"
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ private slots:
|
|||||||
void testRewriterActionCompression();
|
void testRewriterActionCompression();
|
||||||
void testRewriterImports();
|
void testRewriterImports();
|
||||||
void testRewriterChangeImports();
|
void testRewriterChangeImports();
|
||||||
|
void testRewriterUnicodeChars();
|
||||||
|
|
||||||
//
|
//
|
||||||
// unit tests QmlModelNodeFacade/QmlModelState
|
// unit tests QmlModelNodeFacade/QmlModelState
|
||||||
|
|||||||
Reference in New Issue
Block a user