Skip to content

Commit

Permalink
advance enableRawMode() before getColumns()
Browse files Browse the repository at this point in the history
  • Loading branch information
9Ajiang committed Feb 23, 2024
1 parent 93b2db9 commit 4111f1d
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 4111f1d

Please sign in to comment.