diff options
author | Aurindam Jana <aurindam.jana@digia.com> | 2013-03-05 10:50:26 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@digia.com> | 2013-03-05 14:37:26 +0100 |
commit | 7bba366482faf6cd34465a67f076be7f0c41db9a (patch) | |
tree | 03ec024e14d615172858e78be4f944ebae981b20 | |
parent | f57795aaf28ac97e309fa2c12d40ff7374697f5d (diff) | |
download | qt-creator-7bba366482faf6cd34465a67f076be7f0c41db9a.tar.gz |
QmlConsole: Remove zero width space
Zero width space is inserted at every punctuation to
serve as a potential line break. All occurrences should
be removed before sending the expression to JS engine
for evaluation.
Task-number: QTCREATORBUG-8859
Change-Id: I170dfd5fb0f1122ed945bb2e5f77ecaad925004b
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r-- | src/libs/qmljs/consoleitem.cpp | 6 | ||||
-rw-r--r-- | src/libs/qmljs/consoleitem.h | 1 | ||||
-rw-r--r-- | src/plugins/qmljstools/qmlconsoleedit.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qmljstools/qmlconsoleitemdelegate.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmljstools/qmlconsoleitemmodel.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmljstools/qmlconsoleitemmodel.h | 2 | ||||
-rw-r--r-- | src/plugins/qmljstools/qmlconsoleview.cpp | 2 |
7 files changed, 19 insertions, 7 deletions
diff --git a/src/libs/qmljs/consoleitem.cpp b/src/libs/qmljs/consoleitem.cpp index 03da4bdd2f..74cd21137f 100644 --- a/src/libs/qmljs/consoleitem.cpp +++ b/src/libs/qmljs/consoleitem.cpp @@ -149,4 +149,10 @@ const QString &ConsoleItem::text() const return m_text; } +QString ConsoleItem::expression() const +{ + QString text = m_text; + return text.remove(QChar(0x200b)); // ZERO WIDTH SPACE +} + } // QmlJS diff --git a/src/libs/qmljs/consoleitem.h b/src/libs/qmljs/consoleitem.h index 4ad952ec1b..952afc06f7 100644 --- a/src/libs/qmljs/consoleitem.h +++ b/src/libs/qmljs/consoleitem.h @@ -67,6 +67,7 @@ public: int childNumber() const; void setText(const QString &text); const QString &text() const; + QString expression() const; private: ConsoleItem *m_parentItem; diff --git a/src/plugins/qmljstools/qmlconsoleedit.cpp b/src/plugins/qmljstools/qmlconsoleedit.cpp index 7c13b0bc67..22c9609886 100644 --- a/src/plugins/qmljstools/qmlconsoleedit.cpp +++ b/src/plugins/qmljstools/qmlconsoleedit.cpp @@ -213,7 +213,8 @@ void QmlConsoleEdit::handleUpKey() if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data( index, QmlConsoleItemModel::TypeRole).toInt()) { m_historyIndex = index; - replaceCurrentScript(model->data(index, Qt::DisplayRole).toString()); + replaceCurrentScript( + model->data(index, QmlConsoleItemModel::ExpressionRole).toString()); break; } } @@ -232,10 +233,12 @@ void QmlConsoleEdit::handleDownKey() if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data( index, QmlConsoleItemModel::TypeRole).toInt()) { m_historyIndex = index; - if (currentRow == model->rowCount() - 1) + if (currentRow == model->rowCount() - 1) { replaceCurrentScript(m_cachedScript); - else - replaceCurrentScript(model->data(index, Qt::DisplayRole).toString()); + } else { + replaceCurrentScript( + model->data(index, QmlConsoleItemModel::ExpressionRole).toString()); + } break; } } diff --git a/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp index 57435986df..c02f00e708 100644 --- a/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp +++ b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp @@ -313,7 +313,7 @@ void QmlConsoleItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor); - edtr->insertPlainText(index.data(Qt::DisplayRole).toString()); + edtr->insertPlainText(index.data(QmlConsoleItemModel::ExpressionRole).toString()); } void QmlConsoleItemDelegate::setModelData(QWidget *editor, diff --git a/src/plugins/qmljstools/qmlconsoleitemmodel.cpp b/src/plugins/qmljstools/qmlconsoleitemmodel.cpp index a18fd5d11b..a445d062d8 100644 --- a/src/plugins/qmljstools/qmlconsoleitemmodel.cpp +++ b/src/plugins/qmljstools/qmlconsoleitemmodel.cpp @@ -159,6 +159,8 @@ QVariant QmlConsoleItemModel::data(const QModelIndex &index, int role) const return item->file; else if (role == QmlConsoleItemModel::LineRole) return item->line; + else if (role == QmlConsoleItemModel::ExpressionRole) + return item->expression(); else return QVariant(); } diff --git a/src/plugins/qmljstools/qmlconsoleitemmodel.h b/src/plugins/qmljstools/qmlconsoleitemmodel.h index 5cc4f6787f..ff55b9917d 100644 --- a/src/plugins/qmljstools/qmlconsoleitemmodel.h +++ b/src/plugins/qmljstools/qmlconsoleitemmodel.h @@ -43,7 +43,7 @@ class QmlConsoleItemModel : public QAbstractItemModel { Q_OBJECT public: - enum Roles { TypeRole = Qt::UserRole, FileRole, LineRole }; + enum Roles { TypeRole = Qt::UserRole, FileRole, LineRole, ExpressionRole }; explicit QmlConsoleItemModel(QObject *parent = 0); ~QmlConsoleItemModel(); diff --git a/src/plugins/qmljstools/qmlconsoleview.cpp b/src/plugins/qmljstools/qmlconsoleview.cpp index 4e22626a2c..50d45b1c28 100644 --- a/src/plugins/qmljstools/qmlconsoleview.cpp +++ b/src/plugins/qmljstools/qmlconsoleview.cpp @@ -242,7 +242,7 @@ void QmlConsoleView::copyToClipboard(const QModelIndex &index) if (!index.isValid()) return; - QString contents = model()->data(index).toString(); + QString contents = model()->data(index, QmlConsoleItemModel::ExpressionRole).toString(); // See if we have file and line Info QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString(); if (!filePath.isEmpty()) { |