@@ -2107,30 +2107,40 @@ win_equal_rec(
21072107 static void
21082108leaving_window (win_T * win )
21092109{
2110+ // Only matters for a prompt window.
2111+ if (!bt_prompt (win -> w_buffer ))
2112+ return ;
2113+
21102114 // When leaving a prompt window stop Insert mode and perhaps restart
21112115 // it when entering that window again.
21122116 win -> w_buffer -> b_prompt_insert = restart_edit ;
21132117 restart_edit = NUL ;
21142118
21152119 // When leaving the window (or closing the window) was done from a
2116- // callback we need to break out of the Insert mode loop.
2120+ // callback we need to break out of the Insert mode loop and restart Insert
2121+ // mode when entering the window again.
21172122 if (State & INSERT )
21182123 {
21192124 stop_insert_mode = TRUE;
2120- if (bt_prompt ( win -> w_buffer ) && win -> w_buffer -> b_prompt_insert == NUL )
2125+ if (win -> w_buffer -> b_prompt_insert == NUL )
21212126 win -> w_buffer -> b_prompt_insert = 'A' ;
21222127 }
21232128}
21242129
21252130 static void
21262131entering_window (win_T * win )
21272132{
2133+ // Only matters for a prompt window.
2134+ if (!bt_prompt (win -> w_buffer ))
2135+ return ;
2136+
21282137 // When switching to a prompt buffer that was in Insert mode, don't stop
21292138 // Insert mode, it may have been set in leaving_window().
2130- if (bt_prompt ( win -> w_buffer ) && win -> w_buffer -> b_prompt_insert != NUL )
2139+ if (win -> w_buffer -> b_prompt_insert != NUL )
21312140 stop_insert_mode = FALSE;
21322141
2133- // When entering the prompt window may restart Insert mode.
2142+ // When entering the prompt window restart Insert mode if we were in Insert
2143+ // mode when we left it.
21342144 restart_edit = win -> w_buffer -> b_prompt_insert ;
21352145}
21362146#endif
0 commit comments