commit 594ef2225f87b7d17f8221171c1536f08e5373b2
parent 9631e858f2b9a7757e3d5ff020f13482572eeaee
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 13 Dec 2019 13:55:24 +0100
justify: distinguish between tabs and spaces when comparing indentation
That is: two consecutive lines are considered to belong to separate
paragraphs when the smallest indentation of those two lines is not
character-by-character identical with the corresponding piece of
indentation of the other line.
In other words: if one line is indented with spaces, and a consecutive
line is indented by the same distance but with tabs, they are taken to
belong to different paragraphs: a justification will not merge them.
This fixes https://savannah.gnu.org/bugs/?57404.
Bug existed since version 2.9.8, commit 432a7d77.
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -1751,10 +1751,18 @@ bool begpar(const linestruct *const line, int depth)
if (line->prev->data[quote_len + prev_dent_len] == '\0')
return TRUE;
+ /* If the indentation of the preceding line differs characterwise
+ * from the indentation of this line, this IS a BOP. */
+ if (prev_dent_len > 0 && indent_len > 0) {
+ size_t lowest = (prev_dent_len < indent_len ? prev_dent_len : indent_len);
+
+ if (strncmp(line->prev->data + quote_len, line->data + quote_len, lowest) != 0)
+ return TRUE;
+ }
+
/* If the indentation of the preceding line equals the indentation
* of this line, this is not a BOP. */
- if (prev_dent_len == indent_len && strncmp(line->prev->data + quote_len,
- line->data + quote_len, indent_len) == 0)
+ if (prev_dent_len == indent_len)
return FALSE;
/* Otherwise, this is a BOP if the preceding line is not. */