forked from qt-creator/qt-creator
Allow auto matching of string/char literals.
This commit is contained in:
@@ -1276,7 +1276,7 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert
|
|||||||
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
|
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
|
||||||
m_allowSkippingOfBlockEnd = false; // consume blockEnd.
|
m_allowSkippingOfBlockEnd = false; // consume blockEnd.
|
||||||
|
|
||||||
if (!contextAllowsAutoParentheses(cursor))
|
if (!contextAllowsAutoParentheses(cursor, textToInsert))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString text = textToInsert;
|
QString text = textToInsert;
|
||||||
@@ -1374,9 +1374,14 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor) const
|
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor,
|
||||||
|
const QString &textToInsert) const
|
||||||
{
|
{
|
||||||
if (! MatchingText::shouldInsertMatchingText(cursor))
|
QChar ch;
|
||||||
|
if (! textToInsert.isEmpty())
|
||||||
|
ch = textToInsert.at(0);
|
||||||
|
|
||||||
|
if (! (MatchingText::shouldInsertMatchingText(cursor) || ch == QLatin1Char('\'') || ch == QLatin1Char('"')))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CPlusPlus::TokenUnderCursor tokenUnderCursor;
|
CPlusPlus::TokenUnderCursor tokenUnderCursor;
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ protected:
|
|||||||
bool autoBackspace(QTextCursor &cursor);
|
bool autoBackspace(QTextCursor &cursor);
|
||||||
int paragraphSeparatorAboutToBeInserted(QTextCursor &cursor);
|
int paragraphSeparatorAboutToBeInserted(QTextCursor &cursor);
|
||||||
|
|
||||||
bool contextAllowsAutoParentheses(const QTextCursor &cursor) const;
|
bool contextAllowsAutoParentheses(const QTextCursor &cursor,
|
||||||
|
const QString &textToInsert = QString()) const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateFileName();
|
void updateFileName();
|
||||||
|
|||||||
Reference in New Issue
Block a user