Commit 687eeb50 authored by Laurent Montel's avatar Laurent Montel 😁

Fix crash when we add non breaking space

parent 70e9771c
......@@ -482,17 +482,21 @@ void AutoCorrection::addNonBreakingSpace()
}
} else {
//°C (degres)
const QChar previousChar = text.at(mCursor.position() - 2 - block.position());
if (lastChar == QLatin1Char('C') && previousChar == QChar(0x000B0)) {
const int pos = mCursor.position() - 3 - block.position();
if (pos >= 0) {
const QChar previousChar = text.at(pos);
if (previousChar.isSpace()) {
QTextCursor cursor(mCursor);
cursor.setPosition(pos);
cursor.setPosition(pos + 1, QTextCursor::KeepAnchor);
cursor.deleteChar();
mCursor.insertText(mNonBreakingSpace);
const int pos = mCursor.position() - 2 - block.position();
if (pos >= 0) {
const QChar previousChar = text.at(pos);
if (lastChar == QLatin1Char('C') && previousChar == QChar(0x000B0)) {
const int pos = mCursor.position() - 3 - block.position();
if (pos >= 0) {
const QChar previousChar = text.at(pos);
if (previousChar.isSpace()) {
QTextCursor cursor(mCursor);
cursor.setPosition(pos);
cursor.setPosition(pos + 1, QTextCursor::KeepAnchor);
cursor.deleteChar();
mCursor.insertText(mNonBreakingSpace);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment