aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Document.cxx6
-rw-r--r--src/PositionCache.cxx5
2 files changed, 4 insertions, 7 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 7dbe499a2..e6f8f3543 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1314,16 +1314,10 @@ 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);
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 89276d2a0..c332af609 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -377,7 +377,10 @@ void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap
if (!foundBreak) {
if (CpUtf8 == pdoc->dbcsCodePage) {
// Go back before a base character, commonly a letter as modifiers are after the letter they modify
- std::string_view svWithoutLast(&chars[lastLineStart], CharacterBoundary(p + 1, 1) - lastLineStart);
+ const Sci::Position afterLastCharacter = CharacterBoundary(p + 1, 1);
+ const Sci::Position afterWrap = std::min<Sci::Position>(
+ afterLastCharacter, numCharsBeforeEOL + 1); // Limit to one byte of line end
+ std::string_view svWithoutLast(&chars[lastLineStart], afterWrap - lastLineStart);
if (DiscardLastCombinedCharacter(svWithoutLast) && !svWithoutLast.empty()) {
lastGoodBreak = lastLineStart + static_cast<Sci::Position>(svWithoutLast.length());
foundBreak = true;