mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1252: MS-Windows: scrollback cropped off on Vim exit
Problem: MS-Windows: scrollback cropped off on Vim exit. Solution: Don't call SetConsoleScreenBufferInfoEx when using the alternate screen buffer. (Christopher Plewright, closes #11882)
This commit is contained in:
committed by
Bram Moolenaar
parent
fadc02a2a5
commit
f75a2cb3c7
@@ -232,7 +232,8 @@ static guicolor_T store_console_bg_rgb;
|
|||||||
static guicolor_T store_console_fg_rgb;
|
static guicolor_T store_console_fg_rgb;
|
||||||
static int default_console_color_bg = 0x000000; // black
|
static int default_console_color_bg = 0x000000; // black
|
||||||
static int default_console_color_fg = 0xc0c0c0; // white
|
static int default_console_color_fg = 0xc0c0c0; // white
|
||||||
# define USE_VTP (vtp_working && is_term_win32())
|
# define USE_VTP (vtp_working && is_term_win32() \
|
||||||
|
&& (p_tgc || t_colors >= 256))
|
||||||
# define USE_WT (wt_working)
|
# define USE_WT (wt_working)
|
||||||
# else
|
# else
|
||||||
# define USE_VTP 0
|
# define USE_VTP 0
|
||||||
@@ -3463,6 +3464,9 @@ mch_init_c(void)
|
|||||||
ui_get_shellsize();
|
ui_get_shellsize();
|
||||||
|
|
||||||
vtp_init();
|
vtp_init();
|
||||||
|
// Switch to a new alternate screen buffer.
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
vtp_printf("\033[?1049h");
|
||||||
|
|
||||||
# ifdef MCH_WRITE_DUMP
|
# ifdef MCH_WRITE_DUMP
|
||||||
fdDump = fopen("dump", "wt");
|
fdDump = fopen("dump", "wt");
|
||||||
@@ -4437,6 +4441,9 @@ ResizeConBuf(
|
|||||||
HANDLE hConsole,
|
HANDLE hConsole,
|
||||||
COORD coordScreen)
|
COORD coordScreen)
|
||||||
{
|
{
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
|
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
|
||||||
{
|
{
|
||||||
# ifdef MCH_WRITE_DUMP
|
# ifdef MCH_WRITE_DUMP
|
||||||
@@ -6189,12 +6196,6 @@ termcap_mode_start(void)
|
|||||||
if (g_fTermcapMode)
|
if (g_fTermcapMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// VTP uses alternate screen buffer.
|
|
||||||
// Switch to a new alternate screen buffer.
|
|
||||||
// But, not if running in a nested terminal
|
|
||||||
if (use_alternate_screen_buffer)
|
|
||||||
vtp_printf("\033[?1049h");
|
|
||||||
|
|
||||||
SaveConsoleBuffer(&g_cbNonTermcap);
|
SaveConsoleBuffer(&g_cbNonTermcap);
|
||||||
|
|
||||||
if (g_cbTermcap.IsValid)
|
if (g_cbTermcap.IsValid)
|
||||||
@@ -6273,7 +6274,6 @@ termcap_mode_end(void)
|
|||||||
RestoreConsoleBuffer(cb, p_rs);
|
RestoreConsoleBuffer(cb, p_rs);
|
||||||
restore_console_color_rgb();
|
restore_console_color_rgb();
|
||||||
|
|
||||||
// VTP uses alternate screen buffer.
|
|
||||||
// Switch back to main screen buffer.
|
// Switch back to main screen buffer.
|
||||||
if (exiting && use_alternate_screen_buffer)
|
if (exiting && use_alternate_screen_buffer)
|
||||||
vtp_printf("\033[?1049l");
|
vtp_printf("\033[?1049l");
|
||||||
@@ -6285,7 +6285,6 @@ termcap_mode_end(void)
|
|||||||
*/
|
*/
|
||||||
coord.X = 0;
|
coord.X = 0;
|
||||||
coord.Y = (SHORT) (p_rs ? cb->Info.dwCursorPosition.Y : (Rows - 1));
|
coord.Y = (SHORT) (p_rs ? cb->Info.dwCursorPosition.Y : (Rows - 1));
|
||||||
if (!vtp_working)
|
|
||||||
FillConsoleOutputCharacter(g_hConOut, ' ',
|
FillConsoleOutputCharacter(g_hConOut, ' ',
|
||||||
cb->Info.dwSize.X, coord, &dwDummy);
|
cb->Info.dwSize.X, coord, &dwDummy);
|
||||||
/*
|
/*
|
||||||
@@ -6497,11 +6496,7 @@ insert_lines(unsigned cLines)
|
|||||||
clip.Bottom = g_srScrollRegion.Bottom;
|
clip.Bottom = g_srScrollRegion.Bottom;
|
||||||
|
|
||||||
fill.Char.AsciiChar = ' ';
|
fill.Char.AsciiChar = ' ';
|
||||||
if (!(vtp_working
|
if (!USE_VTP)
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
|
||||||
&& (p_tgc || t_colors >= 256)
|
|
||||||
# endif
|
|
||||||
))
|
|
||||||
fill.Attributes = g_attrCurrent;
|
fill.Attributes = g_attrCurrent;
|
||||||
else
|
else
|
||||||
fill.Attributes = g_attrDefault;
|
fill.Attributes = g_attrDefault;
|
||||||
@@ -6625,11 +6620,7 @@ gotoxy(
|
|||||||
if (x < 1 || x > (unsigned)Columns || y < 1 || y > (unsigned)Rows)
|
if (x < 1 || x > (unsigned)Columns || y < 1 || y > (unsigned)Rows)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(vtp_working
|
if (!USE_VTP)
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
|
||||||
&& (p_tgc || t_colors >= 256)
|
|
||||||
# endif
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
// There are reports of double-width characters not displayed
|
// There are reports of double-width characters not displayed
|
||||||
// correctly. This workaround should fix it, similar to how it's done
|
// correctly. This workaround should fix it, similar to how it's done
|
||||||
@@ -6883,11 +6874,7 @@ write_chars(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vtp_working
|
if (!USE_VTP)
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
|
||||||
&& (p_tgc || t_colors >= 256)
|
|
||||||
# endif
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
FillConsoleOutputAttribute(g_hConOut, g_attrCurrent, cells,
|
FillConsoleOutputAttribute(g_hConOut, g_attrCurrent, cells,
|
||||||
coord, &written);
|
coord, &written);
|
||||||
@@ -6927,11 +6914,7 @@ write_chars(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cursor under VTP is always in the correct position, no need to reset.
|
// Cursor under VTP is always in the correct position, no need to reset.
|
||||||
if (!(vtp_working
|
if (!USE_VTP)
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
|
||||||
&& (p_tgc || t_colors >= 256)
|
|
||||||
# endif
|
|
||||||
))
|
|
||||||
gotoxy(g_coord.X + 1, g_coord.Y + 1);
|
gotoxy(g_coord.X + 1, g_coord.Y + 1);
|
||||||
|
|
||||||
return written;
|
return written;
|
||||||
@@ -7227,11 +7210,7 @@ notsgr:
|
|||||||
normvideo();
|
normvideo();
|
||||||
else if (argc == 1)
|
else if (argc == 1)
|
||||||
{
|
{
|
||||||
if (vtp_working
|
if (USE_VTP)
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
|
||||||
&& (p_tgc || t_colors >= 256)
|
|
||||||
# endif
|
|
||||||
)
|
|
||||||
textcolor((WORD)arg1);
|
textcolor((WORD)arg1);
|
||||||
else
|
else
|
||||||
textattr((WORD)arg1);
|
textattr((WORD)arg1);
|
||||||
@@ -8440,6 +8419,11 @@ vtp_flag_init(void)
|
|||||||
mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
mode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||||
if (SetConsoleMode(out, mode) == 0)
|
if (SetConsoleMode(out, mode) == 0)
|
||||||
vtp_working = 0;
|
vtp_working = 0;
|
||||||
|
|
||||||
|
// VTP uses alternate screen buffer.
|
||||||
|
// But, not if running in a nested terminal
|
||||||
|
use_alternate_screen_buffer = win10_22H2_or_later && p_rs && vtp_working
|
||||||
|
&& !mch_getenv("VIM_TERMINAL");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -8485,8 +8469,6 @@ vtp_init(void)
|
|||||||
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
|
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
|
||||||
default_console_color_fg = fg;
|
default_console_color_fg = fg;
|
||||||
# endif
|
# endif
|
||||||
use_alternate_screen_buffer = win10_22H2_or_later && p_rs && vtp_working
|
|
||||||
&& !mch_getenv("VIM_TERMINAL");
|
|
||||||
set_console_color_rgb();
|
set_console_color_rgb();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8707,6 +8689,9 @@ set_console_color_rgb(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
|
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
|
||||||
bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
|
bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
|
||||||
|
|
||||||
@@ -8781,6 +8766,8 @@ get_default_console_color(
|
|||||||
reset_console_color_rgb(void)
|
reset_console_color_rgb(void)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
# ifdef FEAT_TERMGUICOLORS
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
|
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
|
||||||
|
|
||||||
@@ -8803,6 +8790,8 @@ reset_console_color_rgb(void)
|
|||||||
restore_console_color_rgb(void)
|
restore_console_color_rgb(void)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
# ifdef FEAT_TERMGUICOLORS
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
|
CONSOLE_SCREEN_BUFFER_INFOEX csbi;
|
||||||
|
|
||||||
@@ -8875,6 +8864,9 @@ get_conpty_fix_type(void)
|
|||||||
void
|
void
|
||||||
resize_console_buf(void)
|
resize_console_buf(void)
|
||||||
{
|
{
|
||||||
|
if (use_alternate_screen_buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
COORD coord;
|
COORD coord;
|
||||||
SMALL_RECT newsize;
|
SMALL_RECT newsize;
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1252,
|
||||||
/**/
|
/**/
|
||||||
1251,
|
1251,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user