diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-01-30 23:40:14 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-02-13 22:39:51 +0900 |
| commit | 67cb0f6762768ee0d32adef1d7307ff7bb985407 (patch) | |
| tree | 9c391724f3eae5ba2b8279ea9de6245a1f44d25b /src/widgets/qtextedit.cpp | |
| parent | fd79f0c8b020ff0c60b62c83745beb030ef38997 (diff) | |
| download | tqt-67cb0f6762768ee0d32adef1d7307ff7bb985407.tar.gz tqt-67cb0f6762768ee0d32adef1d7307ff7bb985407.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/qtextedit.cpp')
| -rw-r--r-- | src/widgets/qtextedit.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/widgets/qtextedit.cpp b/src/widgets/qtextedit.cpp index bac58af15..73e800be8 100644 --- a/src/widgets/qtextedit.cpp +++ b/src/widgets/qtextedit.cpp @@ -1783,8 +1783,20 @@ void TQTextEdit::doKeyboardAction( KeyboardAction action ) undoRedoInfo.index = cursor->index(); undoRedoInfo.d->text = TQString::null; } - undoRedoInfo.d->text.insert( 0, cursor->paragraph()->at( cursor->index()-1 ), TRUE ); - undoRedoInfo.index = cursor->index()-1; + int cur_idx = cursor->index(); + const TQTextParagraph *para = cursor->paragraph(); + if (para->at(cur_idx - 1)->c.isLowSurrogate() && cur_idx > 1 && + para->at(cur_idx - 2)->c.isHighSurrogate()) + { + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 1), TRUE ); + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 2), TRUE ); + undoRedoInfo.index = cursor->index() - 2; + } + else + { + undoRedoInfo.d->text.insert( 0, para->at(cur_idx - 1), TRUE ); + undoRedoInfo.index = cursor->index() - 1; + } } cursor->removePreviousChar(); lastFormatted = cursor->paragraph(); |
