mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Editor: fix trailing space highlight
This commit is contained in:
parent
35f66ba88e
commit
9a173168ff
@ -175,6 +175,11 @@ void VEditor::highlightOnCursorPositionChanged()
|
|||||||
&& text.size() > 1) {
|
&& text.size() > 1) {
|
||||||
++it;
|
++it;
|
||||||
needUpdate = it->isSpace();
|
needUpdate = it->isSpace();
|
||||||
|
// Input two chars at once in Chinese.
|
||||||
|
if (!needUpdate && text.size() > 2) {
|
||||||
|
++it;
|
||||||
|
needUpdate = it->isSpace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
@ -248,13 +253,17 @@ void VEditor::filterTrailingSpace(QList<QTextEdit::ExtraSelection> &p_selects,
|
|||||||
bool blockEnd = cursor.atBlockEnd();
|
bool blockEnd = cursor.atBlockEnd();
|
||||||
int blockNum = cursor.blockNumber();
|
int blockNum = cursor.blockNumber();
|
||||||
for (auto it = p_src.begin(); it != p_src.end(); ++it) {
|
for (auto it = p_src.begin(); it != p_src.end(); ++it) {
|
||||||
if (blockEnd && it->cursor.blockNumber() == blockNum) {
|
if (it->cursor.blockNumber() == blockNum) {
|
||||||
// When cursor is at block end, we do not display any trailing space
|
if (blockEnd) {
|
||||||
// at current line.
|
// When cursor is at block end, we do not display any trailing space
|
||||||
continue;
|
// at current line.
|
||||||
} else if (!it->cursor.atBlockEnd()) {
|
continue;
|
||||||
// Obsolete trailing space.
|
}
|
||||||
continue;
|
|
||||||
|
QString text = cursor.block().text();
|
||||||
|
if (!text.isEmpty() && !text[text.size() - 1].isSpace()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p_selects.append(*it);
|
p_selects.append(*it);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user