From 277db648049845f19847e62c2a128b970913bbc6 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 13 May 2019 14:05:42 -0700 Subject: [PATCH] Force termsize back to valid in get_current_winsize() get_current_winsize() is intended to be lazy. It does the following: 1. Gets the termsize from the kernel 2. Compares it against the current value 3. If changed, sets COLUMNS and LINES variables Upon setting these variables, we notice that the termsize has changed and invalidate the termsize. Thus we were doing this work multiple times on every screen repaint. Put back an old hack that just marked the termsize as valid at the end of get_current_winsize(). --- src/common.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common.cpp b/src/common.cpp index 71d546c60..f92e31b38 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1843,6 +1843,10 @@ struct winsize get_current_winsize() { // TODO: this may call us reentrantly through the environment dispatch mechanism. We need to // rationalize this. export_new_termsize(&termsize, vars); + // Hack: due to the dispatch the termsize may have just become invalid. Stomp it back to + // valid. What a mess. + *s_termsize.acquire() = termsize; + s_termsize_valid = true; } return termsize; }