mirror of git://git.sv.gnu.org/nano.git
in do_replace_loop(), add new parameter canceled, set to TRUE if we
canceled at the prompt and FALSE otherwise; use it to make sure that canceling works properly in all cases when using the internal spell checker git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2028 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
410efe9a47
commit
9bf486fe5d
|
@ -155,6 +155,9 @@ CVS code -
|
||||||
the spell checker will sometimes only correct the misspelled
|
the spell checker will sometimes only correct the misspelled
|
||||||
word instances that appear before the cursor position and then
|
word instances that appear before the cursor position and then
|
||||||
stop. (Rocco)
|
stop. (Rocco)
|
||||||
|
- Use do_replace_loop()'s canceled parameter in order to ensure
|
||||||
|
that the spell checking stops if we canceled at the replace
|
||||||
|
prompt. (DLR)
|
||||||
do_alt_speller()
|
do_alt_speller()
|
||||||
- Call terminal_init() unconditionally after running the
|
- Call terminal_init() unconditionally after running the
|
||||||
alternate spell checker, so that the terminal state is
|
alternate spell checker, so that the terminal state is
|
||||||
|
@ -221,6 +224,8 @@ CVS code -
|
||||||
replacing only marked text when the mark is on. (DLR,
|
replacing only marked text when the mark is on. (DLR,
|
||||||
suggested by Joseph Birthisel)
|
suggested by Joseph Birthisel)
|
||||||
- Return ssize_t instead of int. (DLR)
|
- Return ssize_t instead of int. (DLR)
|
||||||
|
- Add new parameter canceled, set to TRUE if we canceled at the
|
||||||
|
prompt and FALSE otherwise. (DLR)
|
||||||
- utils.c:
|
- utils.c:
|
||||||
regexp_bol_or_eol()
|
regexp_bol_or_eol()
|
||||||
- Don't assume any longer that string will be found if
|
- Don't assume any longer that string will be found if
|
||||||
|
|
13
src/nano.c
13
src/nano.c
|
@ -1424,7 +1424,7 @@ bool do_int_spell_fix(const char *word)
|
||||||
filestruct *edittop_save = edittop;
|
filestruct *edittop_save = edittop;
|
||||||
filestruct *current_save = current;
|
filestruct *current_save = current;
|
||||||
/* Save where we are. */
|
/* Save where we are. */
|
||||||
bool accepted = TRUE;
|
bool canceled = FALSE;
|
||||||
/* The return value. */
|
/* The return value. */
|
||||||
bool case_sens_set = ISSET(CASE_SENSITIVE);
|
bool case_sens_set = ISSET(CASE_SENSITIVE);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -1477,17 +1477,18 @@ bool do_int_spell_fix(const char *word)
|
||||||
do_replace_highlight(TRUE, word);
|
do_replace_highlight(TRUE, word);
|
||||||
|
|
||||||
/* Allow all instances of the word to be corrected. */
|
/* Allow all instances of the word to be corrected. */
|
||||||
accepted = (statusq(FALSE, spell_list, word,
|
canceled = (statusq(FALSE, spell_list, word,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_("Edit a replacement")) != -1);
|
_("Edit a replacement")) == -1);
|
||||||
|
|
||||||
do_replace_highlight(FALSE, word);
|
do_replace_highlight(FALSE, word);
|
||||||
|
|
||||||
if (accepted && strcmp(word, answer) != 0) {
|
if (!canceled && strcmp(word, answer) != 0) {
|
||||||
current_x--;
|
current_x--;
|
||||||
do_replace_loop(word, current, ¤t_x, TRUE);
|
do_replace_loop(word, current, ¤t_x, TRUE,
|
||||||
|
&canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1526,7 +1527,7 @@ bool do_int_spell_fix(const char *word)
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return accepted;
|
return !canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integrated spell checking using 'spell' program. Return value: NULL
|
/* Integrated spell checking using 'spell' program. Return value: NULL
|
||||||
|
|
|
@ -416,7 +416,7 @@ int replace_regexp(char *string, bool create_flag);
|
||||||
#endif
|
#endif
|
||||||
char *replace_line(const char *needle);
|
char *replace_line(const char *needle);
|
||||||
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
||||||
size_t *real_current_x, bool wholewords);
|
size_t *real_current_x, bool wholewords, bool *canceled);
|
||||||
void do_replace(void);
|
void do_replace(void);
|
||||||
void do_gotoline(int line, bool save_pos);
|
void do_gotoline(int line, bool save_pos);
|
||||||
void do_gotoline_void(void);
|
void do_gotoline_void(void);
|
||||||
|
|
16
src/search.c
16
src/search.c
|
@ -652,9 +652,10 @@ char *replace_line(const char *needle)
|
||||||
* is replaced by a shorter word.
|
* is replaced by a shorter word.
|
||||||
*
|
*
|
||||||
* needle is the string to seek. We replace it with answer. Return -1
|
* needle is the string to seek. We replace it with answer. Return -1
|
||||||
* if needle isn't found, else the number of replacements performed. */
|
* if needle isn't found, else the number of replacements performed. If
|
||||||
|
* canceled isn't NULL, set it to TRUE if we canceled. */
|
||||||
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
||||||
size_t *real_current_x, bool wholewords)
|
size_t *real_current_x, bool wholewords, bool *canceled)
|
||||||
{
|
{
|
||||||
ssize_t numreplaced = -1;
|
ssize_t numreplaced = -1;
|
||||||
size_t match_len;
|
size_t match_len;
|
||||||
|
@ -687,6 +688,9 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (canceled != NULL)
|
||||||
|
*canceled = FALSE;
|
||||||
|
|
||||||
while (findnextstr(TRUE, wholewords,
|
while (findnextstr(TRUE, wholewords,
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
/* We should find a bol and/or eol regex only once per line. If
|
/* We should find a bol and/or eol regex only once per line. If
|
||||||
|
@ -772,8 +776,11 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
||||||
free(exp_word);
|
free(exp_word);
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
if (i == -1) /* We canceled the replace. */
|
if (i == -1) { /* We canceled the replace. */
|
||||||
|
if (canceled != NULL)
|
||||||
|
*canceled = TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
|
@ -937,7 +944,8 @@ void do_replace(void)
|
||||||
beginx = current_x;
|
beginx = current_x;
|
||||||
pww_save = placewewant;
|
pww_save = placewewant;
|
||||||
|
|
||||||
numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE);
|
numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* Restore where we were. */
|
/* Restore where we were. */
|
||||||
edittop = edittop_save;
|
edittop = edittop_save;
|
||||||
|
|
Loading…
Reference in New Issue