~arivigo/sline

22b5cfa710ec05734e8a0cf898c38c74e00a723c — Ariadna Vigo a month ago 18b4d61
Solved history ordering issues when deleting entries
3 files changed, 3 insertions(+), 20 deletions(-)

M history.c
M history.h
M sline.c
M history.c => history.c +0 -14
@@ 45,19 45,5 @@ history_rotate(void)
void
history_set(int pos, const char *input)
{
	/* Ignoring blank lines */
	if (strlen(input) == 0)
		return;

	strlcpy(history[pos], input, hist_entry_size);
}

void
history_del_top(void)
{
	if (hist_top == 0)
		return;

	--hist_top;
	hist_pos = hist_top;
}

M history.h => history.h +0 -1
@@ 6,7 6,6 @@ const char *history_get(int pos);
void history_next(void);
void history_rotate(void);
void history_set(int pos, const char *input);
void history_del_top(void);

extern char *history[HISTORY_SIZE];
extern int hist_top, hist_pos;

M sline.c => sline.c +3 -5
@@ 362,10 362,7 @@ chr_delete(char *buf, size_t size, int bsmode)

	free(suff);

	if (buf_i == 0)
		history_del_top();
	else
		history_set(hist_top, buf);
	history_set(hist_top, buf);
}

static void


@@ 395,7 392,8 @@ chr_ins(char *buf, size_t size, const char *utf8)

	free(suff);

	history_set(hist_top, buf);
	if (strlen(buf) > 0)
		history_set(hist_top, buf);
}

static void