diff options
author | Neil <nyamatongwe@gmail.com> | 2025-02-15 09:13:31 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-02-15 09:13:31 +1100 |
commit | b4f518b2c7c5676b14b80518ddf75a77f39f00b4 (patch) | |
tree | 65bc90d00e8099a3562a87fe192c33a6fc56d877 /src/PositionCache.cxx | |
parent | 0526a5ca6efb68152f88d9a258ef957b808cd831 (diff) | |
download | scintilla-mirror-b4f518b2c7c5676b14b80518ddf75a77f39f00b4.tar.gz |
Fix the previous change to prioritise breaking at style-change and spaces (when
specified) and only discard the last combined character when these fail.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 07f0c9541..596e6f513 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -355,14 +355,8 @@ void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap Sci::Position lastGoodBreak = p; if (p > 0) { lastGoodBreak = CharacterBoundary(p, -1); - 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); - if (DiscardLastCombinedCharacter(svWithoutLast) && !svWithoutLast.empty()) { - lastGoodBreak = lastLineStart + static_cast<Sci::Position>(svWithoutLast.length()); - } - } } + bool foundBreak = false; if (wrapState != Wrap::Char) { Sci::Position pos = lastGoodBreak; while (pos > lastLineStart) { @@ -377,12 +371,23 @@ void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap } if (pos > lastLineStart) { lastGoodBreak = pos; + foundBreak = true; } } - if (lastGoodBreak == lastLineStart) { - // Try moving to start of last character - if (p > 0) { - lastGoodBreak = CharacterBoundary(p, -1); + 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); + if (DiscardLastCombinedCharacter(svWithoutLast) && !svWithoutLast.empty()) { + lastGoodBreak = lastLineStart + static_cast<Sci::Position>(svWithoutLast.length()); + foundBreak = true; + } + } + if (!foundBreak) { + // Try moving to start of last character + if (p > 0) { + lastGoodBreak = CharacterBoundary(p, -1); + } } if (lastGoodBreak == lastLineStart) { // Ensure at least one character on line. |