From e828e256f19446bd3095e91211a828909826c731 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Wed, 4 Sep 2024 15:41:08 -0400 Subject: command history scrolling implemented --- src/history.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/history.c') diff --git a/src/history.c b/src/history.c index 028745e..511f12a 100644 --- a/src/history.c +++ b/src/history.c @@ -151,7 +151,8 @@ void lush_push_history(const char *line) { fprintf(fp, "%s\n", line); // Write the last MAX_LINES lines - for (int i = 0; i < MAX_LINES; i++) { + int total_lines = line_count < MAX_LINES ? line_count : MAX_LINES; + for (int i = 0; i < total_lines; i++) { fprintf(fp, "%s", lines[i]); free(lines[i]); // Free each line after writing } -- cgit v1.2.3-59-g8ed1b