Skip to content

Commit

Permalink
Merge pull request antirez#221 from 9Ajiang/master
Browse files Browse the repository at this point in the history
advance enableRawMode() before getColumns()
  • Loading branch information
antirez authored Feb 23, 2024
2 parents 93b2db9 + 4111f1d commit d895173
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,10 @@ int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, ch
l->plen = strlen(prompt);
l->oldpos = l->pos = 0;
l->len = 0;

/* Enter raw mode. */
if (enableRawMode(l->ifd) == -1) return -1;

l->cols = getColumns(stdin_fd, stdout_fd);
l->oldrows = 0;
l->history_index = 0;
Expand All @@ -893,9 +897,6 @@ int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, ch
* mode later, in linenoiseEditFeed(). */
if (!isatty(l->ifd)) return 0;

/* Enter raw mode. */
if (enableRawMode(l->ifd) == -1) return -1;

/* The latest history entry is always our current buffer, that
* initially is just an empty string. */
linenoiseHistoryAdd("");
Expand Down

0 comments on commit d895173

Please sign in to comment.