Skip to content

Commit

Permalink
Reduce side effects for rl_basic_word_break_characters
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian committed Nov 28, 2023
1 parent b0841a7 commit 1941e94
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,13 @@ readline_set_completer_delims(PyObject *module, PyObject *string)
if (break_chars) {
free(completer_word_break_characters);
completer_word_break_characters = break_chars;
#ifdef WITH_EDITLINE
rl_basic_word_break_characters = break_chars;
#else
if (using_libedit_emulation) {
rl_basic_word_break_characters = break_chars;
}
#endif
rl_completer_word_break_characters = break_chars;
Py_RETURN_NONE;
}
Expand Down Expand Up @@ -1268,7 +1274,15 @@ setup_readline(readlinestate *mod_state)
completer_word_break_characters =
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
/* All nonalphanums except '.' */
#ifdef WITH_EDITLINE
// libedit uses rl_basic_word_break_characters instead of
// rl_completer_word_break_characters as complete delimiter
rl_basic_word_break_characters = completer_word_break_characters;
#else
if (using_libedit_emulation) {
rl_basic_word_break_characters = completer_word_break_characters;
}
#endif
rl_completer_word_break_characters = completer_word_break_characters;

mod_state->begidx = PyLong_FromLong(0L);
Expand Down

0 comments on commit 1941e94

Please sign in to comment.