From b00c1d6110238027e85777b243b170eb18aee93a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 17 Dec 2019 16:15:51 +0100 Subject: [PATCH] justify: treat consecutive indentations that look the same as the same That is: allow tabs and spaces to be mixed when comparing indentation. When the mix of tabs and spaces pushes the text of a line to the same column as on a consecutive line, then those two lines are considered to have the same indentation and thus belong to the same paragraph. This reverts the previous commit (594ef222), and improves upon how nano has behaved since version 2.9.8. This fixes https://savannah.gnu.org/bugs/?57404 differently. --- src/text.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/text.c b/src/text.c index 484c26c4..0896506a 100644 --- a/src/text.c +++ b/src/text.c @@ -1751,18 +1751,9 @@ 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) + /* If indentation of this and preceding line are equal, this is not a BOP. */ + if (wideness(line->prev->data, quote_len + prev_dent_len) == + wideness(line->data, quote_len + indent_len)) return FALSE; /* Otherwise, this is a BOP if the preceding line is not. */