From 0526a5ca6efb68152f88d9a258ef957b808cd831 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 14 Feb 2025 12:24:58 +1100 Subject: For wrapping, try to break lines without separating letters from modifiers. There are still problems for languages like Javanese but it will improve most cases. Unicode proposal to improve line breaking: https://www.unicode.org/L2/L2022/22080r2-line-break-ortho-bnd.pdf --- src/PositionCache.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 5cc8f8fe8..07f0c9541 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -355,6 +355,13 @@ 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(svWithoutLast.length()); + } + } } if (wrapState != Wrap::Char) { Sci::Position pos = lastGoodBreak; -- cgit v1.2.3