summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Bresler <wbresler@gmail.com>2024-10-08 21:30:48 +0200
committerChristian Brabandt <cb@256bit.org>2024-10-08 21:42:46 +0200
commitded59139fde2ba509abbe97f2f23b54080ed59f2 (patch)
treee7e21757511b33638459413184b97daf89238f23
parent830a802f9176ad38f115c18015987a871c99f3a4 (diff)
patch 9.1.0768: MS-Windows: incorrect cursor position when restoring screenv9.1.0768
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>
-rw-r--r--src/os_win32.c11
-rw-r--r--src/version.c2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index e5351b1ce1..81a31409db 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -3556,13 +3556,16 @@ mch_init_c(void)
static void
mch_exit_c(int r)
{
+ // Copy flag since stoptermcap() will clear the flag.
+ int fTermcapMode = g_fTermcapMode;
+
exiting = TRUE;
vtp_exit();
stoptermcap();
- // Switch back to main screen buffer.
- if (use_alternate_screen_buffer)
+ // Switch back to main screen buffer if TermcapMode was not active.
+ if (!fTermcapMode && use_alternate_screen_buffer)
vtp_printf("\033[?1049l");
if (g_fWindInitCalled)
@@ -6338,6 +6341,10 @@ termcap_mode_end(void)
RestoreConsoleBuffer(cb, p_rs);
restore_console_color_rgb();
+ // Switch back to main screen buffer.
+ if (exiting && use_alternate_screen_buffer)
+ vtp_printf("\033[?1049l");
+
if (!USE_WT && (p_rs || exiting))
{
/*
diff --git a/src/version.c b/src/version.c
index 854865f6b0..bff689e653 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 768,
+/**/
767,
/**/
766,