From a467e7914490fe61fd02c15ea596d7a0e90d7cee Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 26 Mar 2018 21:30:45 -0400 Subject: [PATCH] Stop setting title to ";" when 0-length OSC 2 is received Various programs send a 0-length title if no title is configured (e.g., (n)vim with 'title' unset, or mutt without ts_enabled). When this happens, kitty is mis-parsing the data and setting the title to ";". --- kitty/parser.c | 2 +- kitty_tests/parser.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kitty/parser.c b/kitty/parser.c index 43df4bf30..0980a904c 100644 --- a/kitty/parser.c +++ b/kitty/parser.c @@ -310,7 +310,7 @@ dispatch_osc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { } if (i > 0) { code = utoi(screen->parser_buf, i); - if (i < limit - 1 && screen->parser_buf[i] == ';') i++; + if (i < limit && screen->parser_buf[i] == ';') i++; } PyObject *string = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, screen->parser_buf + i, limit - i); if (string != NULL) { diff --git a/kitty_tests/parser.py b/kitty_tests/parser.py index 1e32d1e9a..1643cd7e4 100644 --- a/kitty_tests/parser.py +++ b/kitty_tests/parser.py @@ -182,6 +182,9 @@ class TestParser(BaseTest): c.clear() pb('\033]2;;;;\x07', ('set_title', ';;;')) self.ae(c.titlebuf, ';;;') + c.clear() + pb('\033]2;\x07', ('set_title', '')) + self.ae(c.titlebuf, '') pb('\033]110\x07', ('set_dynamic_color', 110, '')) self.ae(c.colorbuf, '')