Skip to content

Commit 1232624

Browse files
committed
patch 8.0.1261: program in terminal window gets NL instead of CR
Problem: Program in terminal window gets NL instead of CR. (Lifepillar) Solution: Check the tty setup more often. (closes #1998)
1 parent ab8b1c1 commit 1232624

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

src/terminal.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
* in tl_scrollback are no longer used.
3939
*
4040
* TODO:
41+
* - Termdebug: issue #2154 might be avoided by adding -quiet to gdb?
42+
* patch by Christian, 2017 Oct 23.
4143
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
4244
* Higashi, 2017 Sep 19)
4345
* - double click in Window toolbar starts Visual mode (but not always?).
@@ -51,8 +53,6 @@
5153
* Also: #2223
5254
* - implement term_setsize()
5355
* - Termdebug does not work when Vim build with mzscheme. gdb hangs.
54-
* - Termdebug: issue #2154 might be avoided by adding -quiet to gdb?
55-
* patch by Christian, 2017 Oct 23.
5656
* - MS-Windows GUI: WinBar has tearoff item
5757
* - MS-Windows GUI: still need to type a key after shell exits? #1924
5858
* - What to store in a session file? Shell at the prompt would be OK to
@@ -1535,6 +1535,9 @@ terminal_loop(int blocking)
15351535
int c;
15361536
int termkey = 0;
15371537
int ret;
1538+
#ifdef UNIX
1539+
int tty_fd = curbuf->b_term->tl_job->jv_channel->ch_part[get_tty_part(curbuf->b_term)].ch_fd;
1540+
#endif
15381541

15391542
/* Remember the terminal we are sending keys to. However, the terminal
15401543
* might be closed while waiting for a character, e.g. typing "exit" in a
@@ -1547,35 +1550,35 @@ terminal_loop(int blocking)
15471550
position_cursor(curwin, &curbuf->b_term->tl_cursor_pos);
15481551
may_set_cursor_props(curbuf->b_term);
15491552

1550-
#ifdef UNIX
1553+
while (blocking || vpeekc() != NUL)
15511554
{
1552-
int part = get_tty_part(curbuf->b_term);
1553-
int fd = curbuf->b_term->tl_job->jv_channel->ch_part[part].ch_fd;
1555+
/* TODO: skip screen update when handling a sequence of keys. */
1556+
/* Repeat redrawing in case a message is received while redrawing. */
1557+
while (must_redraw != 0)
1558+
if (update_screen(0) == FAIL)
1559+
break;
1560+
update_cursor(curbuf->b_term, FALSE);
15541561

1555-
if (isatty(fd))
1562+
#ifdef UNIX
1563+
/*
1564+
* The shell or another program may change the tty settings. Getting
1565+
* them for every typed character is a bit of overhead, but it's needed
1566+
* for the first CR typed, e.g. when Vim starts in a shell.
1567+
*/
1568+
if (isatty(tty_fd))
15561569
{
15571570
ttyinfo_T info;
15581571

15591572
/* Get the current backspace and enter characters of the pty. */
1560-
if (get_tty_info(fd, &info) == OK)
1573+
if (get_tty_info(tty_fd, &info) == OK)
15611574
{
15621575
term_backspace_char = info.backspace;
15631576
term_enter_char = info.enter;
15641577
term_nl_does_cr = info.nl_does_cr;
15651578
}
15661579
}
1567-
}
15681580
#endif
15691581

1570-
while (blocking || vpeekc() != NUL)
1571-
{
1572-
/* TODO: skip screen update when handling a sequence of keys. */
1573-
/* Repeat redrawing in case a message is received while redrawing. */
1574-
while (must_redraw != 0)
1575-
if (update_screen(0) == FAIL)
1576-
break;
1577-
update_cursor(curbuf->b_term, FALSE);
1578-
15791582
c = term_vgetc();
15801583
if (!term_use_loop())
15811584
/* job finished while waiting for a character */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1261,
764766
/**/
765767
1260,
766768
/**/

0 commit comments

Comments
 (0)