Skip to content

Instantly share code, notes, and snippets.

@k-takata
Created February 16, 2019 02:51
Show Gist options
  • Save k-takata/feb187996d023b243eaf4eb0a01e6bc8 to your computer and use it in GitHub Desktop.
Save k-takata/feb187996d023b243eaf4eb0a01e6bc8 to your computer and use it in GitHub Desktop.
# HG changeset patch
# Parent 8d0990dda8627ba9b7e2647b8f586deb0090f81e
diff --git a/src/os_win32.c b/src/os_win32.c
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1463,6 +1463,8 @@ handle_focus_event(INPUT_RECORD ir)
ui_focus_change((int)g_fJustGotFocus);
}
+static void ResizeConBuf(HANDLE hConsole, COORD coordScreen);
+
/*
* Wait until console input from keyboard or mouse is available,
* or the time is up.
@@ -1628,11 +1630,17 @@ WaitForChar(long msec, int ignore_input)
handle_focus_event(ir);
else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT)
{
+ COORD dwSize = ir.Event.WindowBufferSizeEvent.dwSize;
/* Only call shell_resized() when the size actually change to
* avoid the screen is cleard. */
- if (ir.Event.WindowBufferSizeEvent.dwSize.X != Columns
- || ir.Event.WindowBufferSizeEvent.dwSize.Y != Rows)
+ if (dwSize.X != Columns || dwSize.Y != Rows)
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ GetConsoleScreenBufferInfo(g_hConOut, &csbi);
+ dwSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ ResizeConBuf(g_hConOut, dwSize);
shell_resized();
+ }
}
#ifdef FEAT_MOUSE
else if (ir.EventType == MOUSE_EVENT
@@ -5833,7 +5841,7 @@ write_chars(
// character was written, otherwise we get stuck.
if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length,
coord, &cchwritten) == 0
- || cchwritten == 0)
+ || cchwritten == 0 || cchwritten == (DWORD)-1)
cchwritten = 1;
}
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment