aboutsummaryrefslogtreecommitdiffstats
path: root/src/history.c
diff options
context:
space:
mode:
authorGravatar BanceDev 2024-09-04 15:41:08 -0400
committerGravatar BanceDev 2024-09-04 15:41:08 -0400
commite828e256f19446bd3095e91211a828909826c731 (patch)
tree4637f1e6bf520a19c0cfcc6a04e59f4571092978 /src/history.c
parenthistory saving implemented (diff)
command history scrolling implemented
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c3
1 files changed, 2 insertions, 1 deletions
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
}