From c38739f3bba095d2cbb98cbdb1410a372125f600 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Mon, 19 Aug 2019 18:01:26 +0200 Subject: [PATCH] format: fix addition of fill style newlines in ~< ... ~:@> directive Only add fill style newline for blanks that don't follow a ~ newline directive (see the format.logical-block.23 test in the ansi-test suite). --- src/lsp/format.lsp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lsp/format.lsp b/src/lsp/format.lsp index 91a3cf7d8..1f183c0ce 100644 --- a/src/lsp/format.lsp +++ b/src/lsp/format.lsp @@ -2628,19 +2628,23 @@ insides suffix))) -(defun add-fill-style-newlines (list string offset) +(defun add-fill-style-newlines (list string offset &optional previous-directive-is-newline) (declare (si::c-local)) (if list (let ((directive (car list))) - (if (simple-string-p directive) + (if (and (simple-string-p directive) + (not previous-directive-is-newline)) (nconc (add-fill-style-newlines-aux directive string offset) (add-fill-style-newlines (cdr list) string - (+ offset (length directive)))) + (+ offset (length directive)) + nil)) (cons directive (add-fill-style-newlines (cdr list) string - (format-directive-end directive))))) + (format-directive-end directive) + (char= (format-directive-character directive) + #\newline))))) nil)) (defun add-fill-style-newlines-aux (literal string offset)