From 5f04ceabbc6d28889068b80e8068030abae85888 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 26 Oct 2015 01:14:09 +0100 Subject: [PATCH] Add sleep when saving zoomed windows When saving zoomed windows: - window is un-zoomed - window layout snapshot is taken - window is zoomed back This is done because otherwise tmux does not provide correct window layout. With this we're working around a tmux bug really. The above causes an issue with vim. For some reason vim cannot properly reload it's content when "un-zoom + zoom" is done quickly. Everything works ok if a little sleep/wait is added, so we're doing just that. 0.1 second sleep seems to be enough. About `sleep 0.1 || sleep 1`: this is a hack. We want to wait for 0.1 seconds, which seems to be enough to fix the issue. However, according to POSIX, `sleep` command takes only integers. BUT, decimal values seem to work everywhere. So, we're using a decimal value, and if that fails, we behave POSIX friendly. Related to issue #112. --- scripts/save.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/save.sh b/scripts/save.sh index 63fece9..d861ba5 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -224,6 +224,8 @@ dump_windows() { toggle_window_zoom "${session_name}:${window_index}" # get correct window layout window_layout="$(tmux display-message -p -t "${session_name}:${window_index}" -F "#{window_layout}")" + # sleep required otherwise vim does not redraw correctly, issue #112 + sleep 0.1 || sleep 1 # portability hack # maximize window again toggle_window_zoom "${session_name}:${window_index}" fi