From 8da4993bb4c586b95b4c706094f04adf82ea2ffa Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 24 Oct 2021 09:34:35 +0200 Subject: [PATCH] statusbar: count words in the way that matches how Ctrl+Right moves When --wordbounds (-W) is active, nano considers punctuation as word-forming characters and will thus count words the same way as 'wc -w' does. This is how nano counted words until now. But when --wordbounds is not active (the default), only letters and digits will be considered word-forming and thus lone groups of lines and dashes and other punctuation will not be counted as words, which is more like a human would count words. This addresses https://savannah.gnu.org/bugs/?61367. --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text.c b/src/text.c index 5b2cc782..2c4a822d 100644 --- a/src/text.c +++ b/src/text.c @@ -2960,7 +2960,7 @@ void count_lines_words_and_characters(void) * incrementing the word count for each successful step. */ while (openfile->current->lineno < botline->lineno || (openfile->current == botline && openfile->current_x < bot_x)) { - if (do_next_word(FALSE, TRUE)) + if (do_next_word(FALSE, ISSET(WORD_BOUNDS))) words++; } -- 2.29.3