mirror of
https://github.com/janet-lang/janet
synced 2025-06-11 19:14:13 +00:00
Make history not duplicate itself in getline.
This commit is contained in:
parent
8fbcae6029
commit
64b9482602
@ -299,10 +299,20 @@ static void addhistory(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void replacehistory(void) {
|
static void replacehistory(void) {
|
||||||
|
/* History count is always > 0 here */
|
||||||
|
if (gbl_len == 0 || (gbl_history_count > 1 && !strcmp(gbl_buf, gbl_history[1]))) {
|
||||||
|
/* Delete history */
|
||||||
|
free(gbl_history[0]);
|
||||||
|
for (int i = 1; i < gbl_history_count; i++) {
|
||||||
|
gbl_history[i - 1] = gbl_history[i];
|
||||||
|
}
|
||||||
|
gbl_history_count--;
|
||||||
|
} else {
|
||||||
char *newline = sdup(gbl_buf);
|
char *newline = sdup(gbl_buf);
|
||||||
if (!newline) return;
|
if (!newline) return;
|
||||||
free(gbl_history[0]);
|
free(gbl_history[0]);
|
||||||
gbl_history[0] = newline;
|
gbl_history[0] = newline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kleft(void) {
|
static void kleft(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user