diff --git a/bin/unit_tests/assets/html/whitespace_pre.html b/bin/unit_tests/assets/html/whitespace_pre.html
new file mode 100644
index 000000000..69b6b6876
--- /dev/null
+++ b/bin/unit_tests/assets/html/whitespace_pre.html
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
// in the "LSP Settings" file, under "clients[]"
+"md-lsp": {
+ // default enabled?
+ "enabled": true,
+ "command": [
+ // as long as the system path is setup right, we can find this binary
+ "md-lsp",
+ ],
+ // when we see this scope, the LSP will start this server
+ "selector": "text.html.markdown",
+},
+
+
+
+
diff --git a/src/eepp/graphics/richtext.cpp b/src/eepp/graphics/richtext.cpp
index 0c43a8c9e..f9f81c3ee 100644
--- a/src/eepp/graphics/richtext.cpp
+++ b/src/eepp/graphics/richtext.cpp
@@ -968,17 +968,23 @@ class RichTextInlineLayouter {
}
}
+ bool isLastTextSegment = i + 2 == wrapInfo.wraps.size();
+ bool trailingNewlineAlreadyAdvanced =
+ isNewline && isLastTextSegment && result.lines.back().spans.empty() &&
+ i > 0 && wrapInfo.wraps[i - 1] != wrapInfo.wraps[i];
if ( i < wrapInfo.wraps.size() - 2 || isNewline ) {
if ( isNewline ) {
curCharIdx++;
- if ( i == wrapInfo.wraps.size() - 2 ) {
+ if ( isLastTextSegment ) {
addInlineSpacingToCurrentLine(
result, curX, inlineEndSpacing( payload, inlineItems ) );
}
}
- maxWidth = std::max( maxWidth, curX );
- result.lines.push_back( RichText::RenderParagraph() );
- curX = 0;
+ if ( !trailingNewlineAlreadyAdvanced ) {
+ maxWidth = std::max( maxWidth, curX );
+ result.lines.push_back( RichText::RenderParagraph() );
+ curX = 0;
+ }
}
}
} else {
@@ -1189,17 +1195,23 @@ class RichTextInlineLayouter {
}
}
+ bool isLastTextSegment = i + 2 == wrapInfo.wraps.size();
+ bool trailingNewlineAlreadyAdvanced =
+ isNewline && isLastTextSegment && result.lines.back().spans.empty() &&
+ i > 0 && wrapInfo.wraps[i - 1] != wrapInfo.wraps[i];
if ( i < wrapInfo.wraps.size() - 2 || isNewline ) {
if ( isNewline ) {
curCharIdx++;
- if ( i == wrapInfo.wraps.size() - 2 ) {
+ if ( isLastTextSegment ) {
addInlineSpacingToCurrentLine(
result, curX, inlineEndSpacing( payload, inlineItems ) );
}
}
- maxWidth = std::max( maxWidth, curX );
- result.lines.push_back( RichText::RenderParagraph() );
- curX = 0;
+ if ( !trailingNewlineAlreadyAdvanced ) {
+ maxWidth = std::max( maxWidth, curX );
+ result.lines.push_back( RichText::RenderParagraph() );
+ curX = 0;
+ }
}
}
} else {
diff --git a/src/eepp/ui/uirichtext.cpp b/src/eepp/ui/uirichtext.cpp
index c0f04c8dd..9cbbb0c44 100644
--- a/src/eepp/ui/uirichtext.cpp
+++ b/src/eepp/ui/uirichtext.cpp
@@ -1483,8 +1483,13 @@ static void addProcessedTextSpan( RichText& richText, ProcessedText&& text,
static UIRichText::WhiteSpaceCollapse getEffectiveWhiteSpaceCollapse( Node* node,
UIRichText* fallback ) {
for ( Node* cur = node; cur; cur = cur->getParent() ) {
- if ( cur->isType( UI_TYPE_TEXTSPAN ) || cur->isType( UI_TYPE_RICHTEXT ) )
- return cur->asType