Skip to content

Commit d895173

Browse files
authored
Merge pull request #221 from 9Ajiang/master
advance enableRawMode() before getColumns()
2 parents 93b2db9 + 4111f1d commit d895173

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

linenoise.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,10 @@ int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, ch
880880
l->plen = strlen(prompt);
881881
l->oldpos = l->pos = 0;
882882
l->len = 0;
883+
884+
/* Enter raw mode. */
885+
if (enableRawMode(l->ifd) == -1) return -1;
886+
883887
l->cols = getColumns(stdin_fd, stdout_fd);
884888
l->oldrows = 0;
885889
l->history_index = 0;
@@ -893,9 +897,6 @@ int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, ch
893897
* mode later, in linenoiseEditFeed(). */
894898
if (!isatty(l->ifd)) return 0;
895899

896-
/* Enter raw mode. */
897-
if (enableRawMode(l->ifd) == -1) return -1;
898-
899900
/* The latest history entry is always our current buffer, that
900901
* initially is just an empty string. */
901902
linenoiseHistoryAdd("");

0 commit comments

Comments
 (0)