[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/5] REPL: Fix bug in command line completion.
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 3/5] REPL: Fix bug in command line completion. |
Date: |
Fri, 21 Feb 2020 18:52:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hi John.
If a command (eg: ".info") was entered on the command line and then
changed, using backspace or similar, then the completer for "info"
remained active, although this was not appropriate. This change
corrects this behaviour.
OK for master.
Thanks!
---
ChangeLog | 5 +++++
src/pk-repl.c | 27 +++++++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index aa236add..319c99b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-16 John Darrington <address@hidden>
+
+ * src/pk-repl.c (poke_getc): Revert to poke_completion_function
+ if no complete command is on the repl's command line.
+
2020-02-16 John Darrington <address@hidden>
* src/pk-editor.c (null_complete_function): delete
diff --git a/src/pk-repl.c b/src/pk-repl.c
index cc1d1b71..36f614d8 100644
--- a/src/pk-repl.c
+++ b/src/pk-repl.c
@@ -145,7 +145,6 @@ poke_completion_function (const char *x, int state)
return NULL;
}
-
static char *
null_completion_function (const char *x, int state)
{
@@ -164,17 +163,21 @@ poke_getc (FILE *stream)
strncpy (line_to_point, rl_line_buffer, end);
char *tok = strtok (line_to_point, "\t ");
- if (rl_completion_entry_function == poke_completion_function)
- {
- struct pk_cmd *cmd = pk_cmd_find (tok);
- if (cmd)
- {
- if (cmd->completer)
- rl_completion_entry_function = cmd->completer;
- else
- rl_completion_entry_function = null_completion_function;
- }
- }
+ const struct pk_cmd *cmd = pk_cmd_find (tok);
+
+ if (cmd == NULL)
+ rl_completion_entry_function = poke_completion_function;
+
+ if (rl_completion_entry_function == poke_completion_function)
+ {
+ if (cmd)
+ {
+ if (cmd->completer)
+ rl_completion_entry_function = cmd->completer;
+ else
+ rl_completion_entry_function = null_completion_function;
+ }
+ }
free (line_to_point);
return rl_getc (stream);
- [PATCH 1/5] Explicitly set completer members of pk_cmd structs to NULL where appropriate., John Darrington, 2020/02/21
- [PATCH 5/5] .ios: Add a completer (same as for the .close command), John Darrington, 2020/02/21
- [PATCH 3/5] REPL: Fix bug in command line completion., John Darrington, 2020/02/21
- Re: [PATCH 3/5] REPL: Fix bug in command line completion.,
Jose E. Marchesi <=
- [PATCH 4/5] Fix erroneous completer for the .close command, John Darrington, 2020/02/21
- [PATCH 2/5] REPL: Use null_completion_function as the default, John Darrington, 2020/02/21
- Re: [PATCH 1/5] Explicitly set completer members of pk_cmd structs to NULL where appropriate., Jose E. Marchesi, 2020/02/21