diff options
| author | 2024-09-04 15:41:08 -0400 | |
|---|---|---|
| committer | 2024-09-04 15:41:08 -0400 | |
| commit | e828e256f19446bd3095e91211a828909826c731 (patch) | |
| tree | 4637f1e6bf520a19c0cfcc6a04e59f4571092978 /src/history.c | |
| parent | history saving implemented (diff) | |
command history scrolling implemented
Diffstat (limited to 'src/history.c')
| -rw-r--r-- | src/history.c | 3 |
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 } |
