about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/layout/engine.nim4
-rw-r--r--test/layout/pre-no-trailing-space.expected3
-rw-r--r--test/layout/pre-no-trailing-space.html3
3 files changed, 9 insertions, 1 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 30895b22..7328839a 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -526,7 +526,9 @@ proc putAtom(state: var LineBoxState; atom: InlineAtom;
 proc addSpacing(ictx: var InlineContext; width: LayoutUnit; state: InlineState;
     hang = false) =
   let fragment = ictx.whitespaceFragment
-  if fragment.state.atoms.len == 0 or fragment.state.atoms[^1].t != iatWord:
+  if fragment.state.atoms.len == 0 or ictx.lbstate.atoms.len == 0 or
+      (let oatom = fragment.state.atoms[^1];
+        oatom.t != iatWord or oatom != ictx.lbstate.atoms[^1]):
     let atom = InlineAtom(
       t: iatWord,
       size: size(w = 0, h = ictx.cellHeight),
diff --git a/test/layout/pre-no-trailing-space.expected b/test/layout/pre-no-trailing-space.expected
new file mode 100644
index 00000000..83fdb29d
--- /dev/null
+++ b/test/layout/pre-no-trailing-space.expected
@@ -0,0 +1,3 @@
+
+test
+    test
diff --git a/test/layout/pre-no-trailing-space.html b/test/layout/pre-no-trailing-space.html
new file mode 100644
index 00000000..76b04f34
--- /dev/null
+++ b/test/layout/pre-no-trailing-space.html
@@ -0,0 +1,3 @@
+<pre>
+test
+    test