Skip to content

Commit ded5913

Browse files
thegavaguychrisbra
authored andcommitted
patch 9.1.0768: MS-Windows: incorrect cursor position when restoring screen
Problem: MS-Windows: incorrect cursor position when restoring screen (after v9.1.0664) Solution: Restore the VTP command for switching screens back to termcap_mode_end() (William Bresler) Patch 9.1.0664 moved the VTP command for switching back to the main screen buffer from termcap_mode_end() to mch_exit_c(). However, the saved cursor position from the main screen continued to be restored in termcap_mode_end(). This failed if the cursor position was beyond the console window height, since the alternate screen buffer is always the same size as the console window. This patch restores the VTP command for switching back to the main screen buffer to termcap_mode_end(). In order to preserve the effect of patch 9.1.0664, the VTP command for switching back to the main screen buffer in mch_exit_c() is issued only if termcap mode was not active while exiting Vim. See issue 15775 for a fuller description, with screen shots of the problem. fixes: #15775 closes: #15829 Signed-off-by: William Bresler <wbresler@gmail.com> Signed-off-by: Ken Takata <kentkt@csc.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 830a802 commit ded5913

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/os_win32.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,13 +3556,16 @@ mch_init_c(void)
35563556
static void
35573557
mch_exit_c(int r)
35583558
{
3559+
// Copy flag since stoptermcap() will clear the flag.
3560+
int fTermcapMode = g_fTermcapMode;
3561+
35593562
exiting = TRUE;
35603563

35613564
vtp_exit();
35623565

35633566
stoptermcap();
3564-
// Switch back to main screen buffer.
3565-
if (use_alternate_screen_buffer)
3567+
// Switch back to main screen buffer if TermcapMode was not active.
3568+
if (!fTermcapMode && use_alternate_screen_buffer)
35663569
vtp_printf("\033[?1049l");
35673570

35683571
if (g_fWindInitCalled)
@@ -6338,6 +6341,10 @@ termcap_mode_end(void)
63386341
RestoreConsoleBuffer(cb, p_rs);
63396342
restore_console_color_rgb();
63406343

6344+
// Switch back to main screen buffer.
6345+
if (exiting && use_alternate_screen_buffer)
6346+
vtp_printf("\033[?1049l");
6347+
63416348
if (!USE_WT && (p_rs || exiting))
63426349
{
63436350
/*

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
768,
707709
/**/
708710
767,
709711
/**/

0 commit comments

Comments
 (0)