summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/ui.scm25
-rw-r--r--tests/ui.scm5
2 files changed, 20 insertions, 10 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 9112d55daf..f11c2e9c92 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -393,15 +393,17 @@ converted to a space; sequences of more than one line break are preserved."
          ((#\newline)
           `(,column ,(+ 1 newlines) ,chars))
          (else
-          (let ((chars  (case newlines
-                          ((0) chars)
-                          ((1) (cons #\space chars))
-                          (else
-                           (append (make-list newlines #\newline) chars))))
-                (column (case newlines
-                          ((0) column)
-                          ((1) (+ 1 column))
-                          (else 0))))
+          (let* ((spaces (if (and (pair? chars) (eqv? (car chars) #\.)) 2 1))
+                 (chars  (case newlines
+                           ((0) chars)
+                           ((1)
+                            (append (make-list spaces #\space) chars))
+                           (else
+                            (append (make-list newlines #\newline) chars))))
+                 (column (case newlines
+                           ((0) column)
+                           ((1) (+ spaces column))
+                           (else 0))))
             (let ((chars  (cons chr chars))
                   (column (+ 1 column)))
               (if (> column width)
@@ -414,7 +416,10 @@ converted to a space; sequences of more than one line break are preserved."
                           0
                           ,(if (null? after)
                                before
-                               (append before (cons #\newline (cdr after)))))
+                               (append before
+                                       (cons #\newline
+                                             (drop-while (cut eqv? #\space <>)
+                                                         after)))))
                         `(,column 0 ,chars)))     ; unbreakable
                   `(,column 0 ,chars)))))))))
 
diff --git a/tests/ui.scm b/tests/ui.scm
index 4bf7a779c5..7cc02649e1 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -67,6 +67,11 @@ interface, and powerful string processing.")
                    10)
    #\newline))
 
+(test-equal "fill-paragraph, two spaces after period"
+  "First line.  Second line"
+  (fill-paragraph "First line.
+Second line" 24))
+
 (test-equal "package-specification->name+version+output"
   '(("guile" #f "out")
     ("guile" "2.0.9" "out")