aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-05-16 11:47:33 +1000
committerNeil <nyamatongwe@gmail.com>2025-05-16 11:47:33 +1000
commita9d050f5145f572542c986f1bcdcdf1c3514f1e9 (patch)
tree18c54ebf4dede4a0c4f658a26dcc7e72c2614cc5
parentd740cae0763d8b3730836e9bd558bf44c5e41eb6 (diff)
downloadscintilla-mirror-a9d050f5145f572542c986f1bcdcdf1c3514f1e9.tar.gz
Fix wrapping bug for UTF-8 where \r\n could wrap between the characters.
https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16373
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/Document.cxx6
2 files changed, 10 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index d1fdd16d7..f82671db4 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -612,6 +612,10 @@
Initially only on GTK and Qt.
</li>
<li>
+ Fix wrapping bug for UTF-8 where \r\n could wrap between the characters.
+ <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16373">Notepad++ Pull Request #16373</a>.
+ </li>
+ <li>
On GTK, reset vertical scroll bar synchronously in SCI_SETDOCPOINTER to fix bug where
scroll position not restored in non-wrap mode.
<a href="https://sourceforge.net/p/scintilla/bugs/2416/">Bug #2416</a>.
diff --git a/src/Document.cxx b/src/Document.cxx
index e6f8f3543..7dbe499a2 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1314,10 +1314,16 @@ bool Scintilla::Internal::DiscardLastCombinedCharacter(std::string_view &text) n
// Modified to move Sk (Symbol Modifier) from ccs-base to ccs-extend to preserve modified emoji
// May break before and after Control which is defined as most of ccC? but not some of ccCf and ccCn
// so treat ccCc, ccCs, ccCo as base for now.
+ // Treat \r\n as a single item to avoid separating the characters.
std::string_view truncated = text;
while (truncated.length() > UTF8MaxBytes) {
// Give up when short
+ if (truncated.substr(truncated.length()-2) == "\r\n") {
+ truncated.remove_suffix(2);
+ text = truncated;
+ return true;
+ }
const CharacterExtracted ce = LastCharacter(truncated);
const CharacterCategory cc = CategoriseCharacter(static_cast<int>(ce.character));
truncated.remove_suffix(ce.widthBytes);