Cygwin: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.

- Currently, ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE are cleared
  if cygwin is started in console. These flags will not be recovered
  even when exiting from cygwin. Also note that if ENABLE_EXTENDED_FLAGS
  is once unset, then the flag ENABLE_QUICK_EDIT_MODE it's associated
  with will no longer be preserved. Unfortunately, we're accidentally
  stepping on this in fhandler_console::set_input_mode().

  This patch solves this by carrying forward these flags in the place
  where it had been ignoring them. Since the previous behaviour of
  leaving these flags unset would essentially maintain their existing
  state, adding the carry-over of the flags now should not alter console
  behaviour.
This commit is contained in:
Mitchell Hentges 2022-02-10 10:38:08 -05:00 committed by Takashi Yano
parent 8f2bd6f046
commit 8a95249d73
1 changed files with 5 additions and 3 deletions

View File

@ -458,16 +458,18 @@ void
fhandler_console::set_input_mode (tty::cons_mode m, const termios *t, fhandler_console::set_input_mode (tty::cons_mode m, const termios *t,
const handle_set_t *p) const handle_set_t *p)
{ {
DWORD flags = 0, oflags; DWORD oflags;
WaitForSingleObject (p->input_mutex, mutex_timeout); WaitForSingleObject (p->input_mutex, mutex_timeout);
GetConsoleMode (p->input_handle, &oflags); GetConsoleMode (p->input_handle, &oflags);
DWORD flags = oflags
& (ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE);
switch (m) switch (m)
{ {
case tty::restore: case tty::restore:
flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT; flags |= ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
break; break;
case tty::cygwin: case tty::cygwin:
flags = ENABLE_WINDOW_INPUT; flags |= ENABLE_WINDOW_INPUT;
if (wincap.has_con_24bit_colors () && !con_is_legacy) if (wincap.has_con_24bit_colors () && !con_is_legacy)
flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; flags |= ENABLE_VIRTUAL_TERMINAL_INPUT;
else else