summaryrefslogtreecommitdiffstats
path: root/src/widgets/qlineedit.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-01-30 23:40:14 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-02-13 22:39:51 +0900
commit67cb0f6762768ee0d32adef1d7307ff7bb985407 (patch)
tree9c391724f3eae5ba2b8279ea9de6245a1f44d25b /src/widgets/qlineedit.cpp
parentfd79f0c8b020ff0c60b62c83745beb030ef38997 (diff)
downloadtqt-67cb0f67.tar.gz
tqt-67cb0f67.zip
Fix editing of text containing surrogate characters.
This relates to issue #162. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 9c648bea9bfb1113c070a05b36f78ff006d0877a)
Diffstat (limited to 'src/widgets/qlineedit.cpp')
-rw-r--r--src/widgets/qlineedit.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/widgets/qlineedit.cpp b/src/widgets/qlineedit.cpp
index bcf9b2d0d..eba3f6b20 100644
--- a/src/widgets/qlineedit.cpp
+++ b/src/widgets/qlineedit.cpp
@@ -877,10 +877,18 @@ void TQLineEdit::backspace()
if ( d->hasSelectedText() ) {
d->removeSelectedText();
} else if ( d->cursor ) {
+ --d->cursor;
+ if ( d->maskData ) {
+ d->cursor = d->prevMaskBlank( d->cursor );
+ }
+ // second half of a surrogate, check if we have the first half as well,
+ // if yes delete both at once
+ if (d->cursor > 0 && d->text.at(d->cursor).isLowSurrogate() &&
+ d->text.at(d->cursor - 1).isHighSurrogate()) {
+ d->del(true);
--d->cursor;
- if ( d->maskData )
- d->cursor = d->prevMaskBlank( d->cursor );
- d->del( TRUE );
+ }
+ d->del(true);
}
d->finishChange( priorState );
}