[PATCH] Cygwin: console: Ignore intermediate byte in CSI sequence

Takashi Yano takashi.yano@nifty.ne.jp
Sun Dec 8 13:35:19 GMT 2024


Recent vim throughs the sequence CSI '0%m' that cannot be handled
appropriately by psuedo console for a test purpose. This patch
removes the intermediate byte ('%') from the sequence.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
 winsup/cygwin/fhandler/console.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 0660ee305..c6c261420 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -4024,6 +4024,11 @@ fhandler_console::write (const void *vsrc, size_t len)
 	case gotcommand:
 	  if (con.nargs < MAXARGS)
 	    con.nargs++;
+	  if (*src == '%' && con.nargs == 1 && con.args[0] == 0)
+	    { /* Ignore intermediate byte in CSI sequence used by vim. */
+	      src++;
+	      break;
+	    }
 	  char_command (*src++);
 	  con.state = normal;
 	  wpbuf.empty();
-- 
2.45.1



More information about the Cygwin-patches mailing list