about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-28 00:13:07 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-28 01:00:12 +0200
commit4f64400ec3f2928b72085750d07a5ac5b6acdb50 (patch)
tree6fafed9aff3e937feec517dc32d6e2756a237499 /src
parentec37eee0d637cc36347cc1e6093c0027f80bdcc1 (diff)
downloadchawan-4f64400ec3f2928b72085750d07a5ac5b6acdb50.tar.gz
layout: count spacing before inline padding too
Diffstat (limited to 'src')
-rw-r--r--src/layout/engine.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index adf691ef..6236825d 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -76,9 +76,17 @@ func cellheight(viewport: Viewport): LayoutUnit =
 func cellheight(ictx: InlineContext): LayoutUnit =
   ictx.viewport.cellheight
 
+# Check if the last atom on the current line is a spacing atom, not counting
+# padding atoms.
 func hasLastSpacing(ictx: InlineContext): bool =
-  return ictx.currentLine.atoms[^1] of InlineSpacing and
-    not (ictx.currentLine.atoms[^1] of InlinePadding)
+  for i in countdown(ictx.currentLine.atoms.high, 0):
+    if ictx.currentLine.atoms[i] of InlineSpacing:
+      if ictx.currentLine.atoms[i] of InlinePadding:
+        continue # skip padding
+      return true
+    else:
+      break
+  return false
 
 # Whitespace between words
 func computeShift(ictx: InlineContext, computed: CSSComputedValues):