From 8704dde8736bf702ff470b39ea8ad3413b3e4486 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 23 Mar 2016 09:52:34 +0000 Subject: [PATCH] Preventing the internal spell checker from finding the first occurrence of a misspelled word twice. And deleting the piece of dead code that was meant to do this. This fixes Savannah bug #47188. When we've reached again the same line where we started and we find an instance there, then this can only be /before or at/ the position from where we started, otherwise we would have found it when we commenced searching. And so... that little piece of dead code does absolutely nothing -- it will never fire. It's so nice... nano is full of Easter Eggs! :) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5760 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/search.c | 21 ++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b99a8dc..59d257fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Benno Schulenberg + * src/search.c (findnextstr): Prevent the internal spell checker from + finding the first occurrence twice. And delete the piece of dead code + that was meant to do this. This fixes Savannah bug #47188. + 2016-03-22 Thomas Rosenau * configure.ac, src/*.c: Check for the existence of the REG_ENHANCED regex flag, and use it when it's available (on OS X systems). This diff --git a/src/search.c b/src/search.c index 4172e123..271e7a42 100644 --- a/src/search.c +++ b/src/search.c @@ -300,6 +300,13 @@ bool findnextstr( #ifndef DISABLE_SPELLER bool found_whole = FALSE; /* Is this potential match a whole word? */ + + /* When we're spell-checking, don't search in the starting line + * again -- there is no need: we started at x = 0. */ + if (whole_word_only && search_last_line) { + disable_nodelay(); + return FALSE; + } #endif /* Set found_len to the length of the potential match. */ @@ -377,20 +384,8 @@ bool findnextstr( /* We found an instance. */ current_x_find = found - fileptr->data; - /* Ensure we haven't wrapped around again! */ - if (search_last_line && -#ifndef NANO_TINY - ((!ISSET(BACKWARDS_SEARCH) && current_x_find > begin_x) || - (ISSET(BACKWARDS_SEARCH) && current_x_find < begin_x))) { -#else - current_x_find > begin_x) { -#endif - not_found_msg(needle); - disable_nodelay(); - return FALSE; - } - disable_nodelay(); + /* We've definitely found something. */ openfile->current = fileptr; openfile->current_x = current_x_find; -- 2.39.5