Skip to content

Commit

Permalink
make rlwrap accept pre-given output even when ENTER is pressed before…
Browse files Browse the repository at this point in the history
… first cooking time
  • Loading branch information
hanslub42 committed Nov 24, 2014
1 parent b6fc14d commit 129f13b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,10 @@ main_loop()
}
if (!skip_rlwrap()) { /* ... or else, it is time to cook the prompt */
if (pre_given && accepted_lines == 0) {
saved_rl_state.input_buffer = mysavestring(pre_given); /* stuff pre-given text into edit buffer */
saved_rl_state.point = strlen(pre_given);
/* input_buffer and point have already been set in init_readline() */
DPRINTF0(DEBUG_READLINE, "Starting line edit (because of -P option)");
within_line_edit = TRUE;
restore_rl_state();

continue;
}

Expand Down
6 changes: 5 additions & 1 deletion src/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ init_readline(char *prompt)

rl_catch_signals = FALSE;
rl_catch_sigwinch = FALSE;
saved_rl_state.input_buffer = mysavestring("");
saved_rl_state.input_buffer = mysavestring(pre_given ? pre_given : ""); /* Even though the pre-given input won't be displayed before the first
cooking takes place, we still want it to be accepted when the user
presses ENTER before that (e.g. because she already knows the
pre-given input and wants to accept that) */
saved_rl_state.point = strlen(saved_rl_state.input_buffer);
saved_rl_state.raw_prompt = mysavestring("");
saved_rl_state.cooked_prompt = NULL;

Expand Down

0 comments on commit 129f13b

Please sign in to comment.