24e9f2ba45621cc3a046b2f32ec9c39fd3e7494b — Ariadna Vigo 7 months ago 22b5cfa
sline.c: edited history entries treated now like new user input

Now if the user navigates through the input history and decides to
reuse the contents of one entry, edits those, and presses return, the
new edited version is added to the end of the history, leaving the
original unedited.
1 files changed, 6 insertions(+), 4 deletions(-)

M sline.c
M sline.c => sline.c +6 -4
@@ 50,7 50,7 @@ static void key_end(char *buf);

static void chr_delete(char *buf, size_t size, int bsmode);
static void chr_ins(char *buf, size_t size, const char *utf8);
static void chr_return(void);
static void chr_return(const char *buf);

static char sline_prompt[SLINE_PROMPT_SIZE];
static size_t pos, buf_i;

@@ 397,11 397,13 @@ chr_ins(char *buf, size_t size, const char *utf8)

static void
chr_return(const char *buf)
	write(STDOUT_FILENO, "\n", 1);
	if (sline_history > 0)
	if (sline_history > 0) {
		history_set(hist_pos, buf);

/* Public sline API subroutines follow */

@@ 452,7 454,7 @@ sline(char *buf, int size, const char *init)
			sline_err = SLINE_ERR_EOF;
			return -1;
		case VT_RET:
			return 0;
		case VT_UP:
			key_up(buf, wsize);