Patch 9.0.1571
Problem:    RedrawingDisabled not used consistently.
Solution:   Avoid RedrawingDisabled going negative.  Set RedrawingDisabled in
            win_split_ins(). (closes #11961)
Files:      src/autocmd.c, src/buffer.c, src/cmdexpand.c, src/debugger.c,
            src/edit.c, src/ex_cmds.c, src/ex_docmd.c, src/ex_getln.c,
            src/insexpand.c, src/os_unix.c, src/popupmenu.c, src/screen.c,
            src/tag.c, src/userfunc.c, src/window.c


*** ../vim-9.0.1570/src/autocmd.c       2023-04-15 13:17:22.875094544 +0100
--- src/autocmd.c       2023-05-20 13:47:09.770601621 +0100
***************
*** 1602,1611 ****
        p_acd = FALSE;
  #endif
  
-       // no redrawing and don't set the window title
-       ++RedrawingDisabled;
        (void)win_split_ins(0, WSP_TOP, auc_win, 0);
-       --RedrawingDisabled;
        (void)win_comp_pos();   // recompute window positions
        p_ea = save_ea;
  #ifdef FEAT_AUTOCHDIR
--- 1602,1608 ----
***************
*** 2334,2340 ****
            active_apc_list = patcmd.next;
      }
  
!     --RedrawingDisabled;
      autocmd_busy = save_autocmd_busy;
      filechangeshell_busy = FALSE;
      autocmd_nested = save_autocmd_nested;
--- 2331,2338 ----
            active_apc_list = patcmd.next;
      }
  
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
      autocmd_busy = save_autocmd_busy;
      filechangeshell_busy = FALSE;
      autocmd_nested = save_autocmd_nested;
*** ../vim-9.0.1570/src/buffer.c        2023-05-14 17:24:18.148997087 +0100
--- src/buffer.c        2023-05-20 13:48:23.294520845 +0100
***************
*** 2506,2516 ****
      }
  
      ++RedrawingDisabled;
      if (GETFILE_SUCCESS(getfile(buf->b_fnum, NULL, NULL,
                                     (options & GETF_SETMARK), lnum, forceit)))
      {
-       --RedrawingDisabled;
- 
        // cursor is at to BOL and w_cursor.lnum is checked due to getfile()
        if (!p_sol && col != 0)
        {
--- 2506,2515 ----
      }
  
      ++RedrawingDisabled;
+     int retval = FAIL;
      if (GETFILE_SUCCESS(getfile(buf->b_fnum, NULL, NULL,
                                     (options & GETF_SETMARK), lnum, forceit)))
      {
        // cursor is at to BOL and w_cursor.lnum is checked due to getfile()
        if (!p_sol && col != 0)
        {
***************
*** 2519,2528 ****
            curwin->w_cursor.coladd = 0;
            curwin->w_set_curswant = TRUE;
        }
!       return OK;
      }
!     --RedrawingDisabled;
!     return FAIL;
  }
  
  /*
--- 2518,2529 ----
            curwin->w_cursor.coladd = 0;
            curwin->w_set_curswant = TRUE;
        }
!       retval = OK;
      }
! 
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
!     return retval;
  }
  
  /*
*** ../vim-9.0.1570/src/cmdexpand.c     2023-05-06 22:21:07.247211940 +0100
--- src/cmdexpand.c     2023-05-20 13:50:02.070417741 +0100
***************
*** 3937,3950 ****
  wildmenu_cleanup(cmdline_info_T *cclp UNUSED)
  {
      int skt = KeyTyped;
- #ifdef FEAT_EVAL
-     int old_RedrawingDisabled = RedrawingDisabled;
- #endif
  
      if (!p_wmnu || wild_menu_showing == 0)
        return;
  
  #ifdef FEAT_EVAL
      if (cclp->input_fn)
        RedrawingDisabled = 0;
  #endif
--- 3937,3948 ----
  wildmenu_cleanup(cmdline_info_T *cclp UNUSED)
  {
      int skt = KeyTyped;
  
      if (!p_wmnu || wild_menu_showing == 0)
        return;
  
  #ifdef FEAT_EVAL
+     int save_RedrawingDisabled = RedrawingDisabled;
      if (cclp->input_fn)
        RedrawingDisabled = 0;
  #endif
***************
*** 3974,3980 ****
      wild_menu_showing = 0;
  #ifdef FEAT_EVAL
      if (cclp->input_fn)
!       RedrawingDisabled = old_RedrawingDisabled;
  #endif
  }
  
--- 3972,3978 ----
      wild_menu_showing = 0;
  #ifdef FEAT_EVAL
      if (cclp->input_fn)
!       RedrawingDisabled = save_RedrawingDisabled;
  #endif
  }
  
*** ../vim-9.0.1570/src/debugger.c      2023-03-07 17:45:07.180247902 +0000
--- src/debugger.c      2023-05-20 13:50:52.346367316 +0100
***************
*** 287,293 ****
      }
      vim_free(cmdline);
  
!     --RedrawingDisabled;
      --no_wait_return;
      redraw_all_later(UPD_NOT_VALID);
      need_wait_return = FALSE;
--- 287,294 ----
      }
      vim_free(cmdline);
  
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
      --no_wait_return;
      redraw_all_later(UPD_NOT_VALID);
      need_wait_return = FALSE;
*** ../vim-9.0.1570/src/edit.c  2023-05-12 15:47:21.856773279 +0100
--- src/edit.c  2023-05-20 13:26:21.199715231 +0100
***************
*** 3613,3619 ****
      temp = curwin->w_cursor.col;
      if (disabled_redraw)
      {
!       --RedrawingDisabled;
        disabled_redraw = FALSE;
      }
      if (!arrow_used)
--- 3613,3620 ----
      temp = curwin->w_cursor.col;
      if (disabled_redraw)
      {
!       if (RedrawingDisabled > 0)
!           --RedrawingDisabled;
        disabled_redraw = FALSE;
      }
      if (!arrow_used)
*** ../vim-9.0.1570/src/ex_cmds.c       2023-05-10 16:53:23.872081797 +0100
--- src/ex_cmds.c       2023-05-20 13:29:20.295569177 +0100
***************
*** 3219,3225 ****
        (void)keymap_init();
  #endif
  
!     --RedrawingDisabled;
      did_inc_redrawing_disabled = FALSE;
      if (!skip_redraw)
      {
--- 3219,3226 ----
        (void)keymap_init();
  #endif
  
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
      did_inc_redrawing_disabled = FALSE;
      if (!skip_redraw)
      {
***************
*** 3263,3269 ****
  #endif
  
  theend:
!     if (did_inc_redrawing_disabled)
        --RedrawingDisabled;
  #if defined(FEAT_EVAL)
      if (did_set_swapcommand)
--- 3264,3270 ----
  #endif
  
  theend:
!     if (did_inc_redrawing_disabled && RedrawingDisabled > 0)
        --RedrawingDisabled;
  #if defined(FEAT_EVAL)
      if (did_set_swapcommand)
***************
*** 3735,3741 ****
      int               sublen;
      int               got_quit = FALSE;
      int               got_match = FALSE;
-     int               temp;
      int               which_pat;
      char_u    *cmd;
      int               save_State;
--- 3736,3741 ----
***************
*** 4316,4322 ****
  #endif
                            // Invert the matched string.
                            // Remove the inversion afterwards.
!                           temp = RedrawingDisabled;
                            RedrawingDisabled = 0;
  
                            // avoid calling update_screen() in vgetorpeek()
--- 4316,4322 ----
  #endif
                            // Invert the matched string.
                            // Remove the inversion afterwards.
!                           int save_RedrawingDisabled = RedrawingDisabled;
                            RedrawingDisabled = 0;
  
                            // avoid calling update_screen() in vgetorpeek()
***************
*** 4386,4392 ****
                            msg_scroll = i;
                            showruler(TRUE);
                            windgoto(msg_row, msg_col);
!                           RedrawingDisabled = temp;
  
  #ifdef USE_ON_FLY_SCROLL
                            dont_scroll = FALSE; // allow scrolling here
--- 4386,4392 ----
                            msg_scroll = i;
                            showruler(TRUE);
                            windgoto(msg_row, msg_col);
!                           RedrawingDisabled = save_RedrawingDisabled;
  
  #ifdef USE_ON_FLY_SCROLL
                            dont_scroll = FALSE; // allow scrolling here
*** ../vim-9.0.1570/src/ex_docmd.c      2023-05-10 16:53:23.872081797 +0100
--- src/ex_docmd.c      2023-05-20 13:55:09.286126312 +0100
***************
*** 550,556 ****
  #ifdef FEAT_GUI
      --hold_gui_events;
  #endif
!     --RedrawingDisabled;
      --no_wait_return;
      update_screen(UPD_CLEAR);
      need_wait_return = FALSE;
--- 550,557 ----
  #ifdef FEAT_GUI
      --hold_gui_events;
  #endif
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
      --no_wait_return;
      update_screen(UPD_CLEAR);
      need_wait_return = FALSE;
***************
*** 631,637 ****
      static int        recursive = 0;          // recursive depth
      int               msg_didout_before_start = 0;
      int               count = 0;              // line number count
!     int               did_inc = FALSE;        // incremented RedrawingDisabled
      int               retval = OK;
  #ifdef FEAT_EVAL
      cstack_T  cstack;                 // conditional stack
--- 632,638 ----
      static int        recursive = 0;          // recursive depth
      int               msg_didout_before_start = 0;
      int               count = 0;              // line number count
!     int               did_inc_RedrawingDisabled = FALSE;
      int               retval = OK;
  #ifdef FEAT_EVAL
      cstack_T  cstack;                 // conditional stack
***************
*** 977,983 ****
                msg_scroll = TRUE;  // put messages below each other
                ++no_wait_return;   // don't wait for return until finished
                ++RedrawingDisabled;
!               did_inc = TRUE;
            }
        }
  
--- 978,984 ----
                msg_scroll = TRUE;  // put messages below each other
                ++no_wait_return;   // don't wait for return until finished
                ++RedrawingDisabled;
!               did_inc_RedrawingDisabled = TRUE;
            }
        }
  
***************
*** 1336,1344 ****
       * hit return before redrawing the screen. With the ":global" command we 
do
       * this only once after the command is finished.
       */
!     if (did_inc)
      {
!       --RedrawingDisabled;
        --no_wait_return;
        msg_scroll = FALSE;
  
--- 1337,1346 ----
       * hit return before redrawing the screen. With the ":global" command we 
do
       * this only once after the command is finished.
       */
!     if (did_inc_RedrawingDisabled)
      {
!       if (RedrawingDisabled > 0)
!           --RedrawingDisabled;
        --no_wait_return;
        msg_scroll = FALSE;
  
***************
*** 7170,7176 ****
  
                if (exmode_was != EXMODE_VIM)
                    settmode(TMODE_RAW);
!               int save_rd = RedrawingDisabled;
                RedrawingDisabled = 0;
                int save_nwr = no_wait_return;
                no_wait_return = 0;
--- 7172,7178 ----
  
                if (exmode_was != EXMODE_VIM)
                    settmode(TMODE_RAW);
!               int save_RedrawingDisabled = RedrawingDisabled;
                RedrawingDisabled = 0;
                int save_nwr = no_wait_return;
                no_wait_return = 0;
***************
*** 7187,7193 ****
                main_loop(FALSE, TRUE);
  
                pending_exmode_active = FALSE;
!               RedrawingDisabled = save_rd;
                no_wait_return = save_nwr;
                msg_scroll = save_ms;
  #ifdef FEAT_GUI
--- 7189,7195 ----
                main_loop(FALSE, TRUE);
  
                pending_exmode_active = FALSE;
!               RedrawingDisabled = save_RedrawingDisabled;
                no_wait_return = save_nwr;
                msg_scroll = save_ms;
  #ifdef FEAT_GUI
***************
*** 8438,8448 ****
      void
  redraw_cmd(int clear)
  {
!     int               r = RedrawingDisabled;
!     int               p = p_lz;
! 
      RedrawingDisabled = 0;
      p_lz = FALSE;
      validate_cursor();
      update_topline();
      update_screen(clear ? UPD_CLEAR : VIsual_active ? UPD_INVERTED : 0);
--- 8440,8451 ----
      void
  redraw_cmd(int clear)
  {
!     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
+ 
+     int save_p_lz = p_lz;
      p_lz = FALSE;
+ 
      validate_cursor();
      update_topline();
      update_screen(clear ? UPD_CLEAR : VIsual_active ? UPD_INVERTED : 0);
***************
*** 8454,8461 ****
  # endif
        resize_console_buf();
  #endif
!     RedrawingDisabled = r;
!     p_lz = p;
  
      // After drawing the statusline screen_attr may still be set.
      screen_stop_highlight();
--- 8457,8464 ----
  # endif
        resize_console_buf();
  #endif
!     RedrawingDisabled = save_RedrawingDisabled;
!     p_lz = save_p_lz;
  
      // After drawing the statusline screen_attr may still be set.
      screen_stop_highlight();
***************
*** 8480,8488 ****
      static void
  ex_redrawstatus(exarg_T *eap UNUSED)
  {
-     int               r = RedrawingDisabled;
-     int               p = p_lz;
- 
      if (eap->forceit)
        status_redraw_all();
      else
--- 8483,8488 ----
***************
*** 8490,8503 ****
      if (msg_scrolled && (State & MODE_CMDLINE))
        return;  // redraw later
  
      RedrawingDisabled = 0;
      p_lz = FALSE;
      if (State & MODE_CMDLINE)
        redraw_statuslines();
      else
        update_screen(VIsual_active ? UPD_INVERTED : 0);
!     RedrawingDisabled = r;
!     p_lz = p;
      out_flush();
  }
  
--- 8490,8507 ----
      if (msg_scrolled && (State & MODE_CMDLINE))
        return;  // redraw later
  
+     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
+ 
+     int save_p_lz = p_lz;
      p_lz = FALSE;
+ 
      if (State & MODE_CMDLINE)
        redraw_statuslines();
      else
        update_screen(VIsual_active ? UPD_INVERTED : 0);
!     RedrawingDisabled = save_RedrawingDisabled;
!     p_lz = save_p_lz;
      out_flush();
  }
  
***************
*** 8507,8522 ****
      static void
  ex_redrawtabline(exarg_T *eap UNUSED)
  {
!     int               r = RedrawingDisabled;
!     int               p = p_lz;
! 
      RedrawingDisabled = 0;
      p_lz = FALSE;
  
      draw_tabline();
  
!     RedrawingDisabled = r;
!     p_lz = p;
      out_flush();
  }
  
--- 8511,8526 ----
      static void
  ex_redrawtabline(exarg_T *eap UNUSED)
  {
!     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
+ 
+     int save_p_lz = p_lz;
      p_lz = FALSE;
  
      draw_tabline();
  
!     RedrawingDisabled = save_RedrawingDisabled;
!     p_lz = save_p_lz;
      out_flush();
  }
  
*** ../vim-9.0.1570/src/ex_getln.c      2023-05-13 13:55:05.842074029 +0100
--- src/ex_getln.c      2023-05-20 13:34:46.671330189 +0100
***************
*** 4545,4551 ****
      if (restart_edit != 0)    // autocmd with ":startinsert"
        stuffcharReadbuff(K_NOP);
  
!     i = RedrawingDisabled;
      RedrawingDisabled = 0;
  
      /*
--- 4545,4551 ----
      if (restart_edit != 0)    // autocmd with ":startinsert"
        stuffcharReadbuff(K_NOP);
  
!     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
  
      /*
***************
*** 4553,4559 ****
       */
      main_loop(TRUE, FALSE);
  
!     RedrawingDisabled = i;
  
  # ifdef FEAT_FOLDING
      save_KeyTyped = KeyTyped;
--- 4553,4559 ----
       */
      main_loop(TRUE, FALSE);
  
!     RedrawingDisabled = save_RedrawingDisabled;
  
  # ifdef FEAT_FOLDING
      save_KeyTyped = KeyTyped;
*** ../vim-9.0.1570/src/insexpand.c     2023-04-22 22:54:28.049802336 +0100
--- src/insexpand.c     2023-05-20 13:36:07.083274951 +0100
***************
*** 2969,2980 ****
      void
  f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
  {
!     int               saved = RedrawingDisabled;
! 
      RedrawingDisabled = 0;
      ins_compl_check_keys(0, TRUE);
      rettv->vval.v_number = ins_compl_interrupted();
!     RedrawingDisabled = saved;
  }
  
  /*
--- 2969,2981 ----
      void
  f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
  {
!     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
+ 
      ins_compl_check_keys(0, TRUE);
      rettv->vval.v_number = ins_compl_interrupted();
! 
!     RedrawingDisabled = save_RedrawingDisabled;
  }
  
  /*
***************
*** 5079,5086 ****
  show_pum(int prev_w_wrow, int prev_w_leftcol)
  {
      // RedrawingDisabled may be set when invoked through complete().
!     int n = RedrawingDisabled;
! 
      RedrawingDisabled = 0;
  
      // If the cursor moved or the display scrolled we need to remove the pum
--- 5080,5086 ----
  show_pum(int prev_w_wrow, int prev_w_leftcol)
  {
      // RedrawingDisabled may be set when invoked through complete().
!     int save_RedrawingDisabled = RedrawingDisabled;
      RedrawingDisabled = 0;
  
      // If the cursor moved or the display scrolled we need to remove the pum
***************
*** 5091,5097 ****
  
      ins_compl_show_pum();
      setcursor();
!     RedrawingDisabled = n;
  }
  
  /*
--- 5091,5098 ----
  
      ins_compl_show_pum();
      setcursor();
! 
!     RedrawingDisabled = save_RedrawingDisabled;
  }
  
  /*
*** ../vim-9.0.1570/src/os_unix.c       2023-05-11 22:25:37.677434047 +0100
--- src/os_unix.c       2023-05-20 13:36:41.779251451 +0100
***************
*** 4594,4600 ****
  
      // Only require pressing Enter when redrawing, to avoid that system() gets
      // the hit-enter prompt even though it didn't output anything.
!     if (!RedrawingDisabled)
        wait_return(TRUE);
      do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE);
  
--- 4594,4600 ----
  
      // Only require pressing Enter when redrawing, to avoid that system() gets
      // the hit-enter prompt even though it didn't output anything.
!     if (RedrawingDisabled == 0)
        wait_return(TRUE);
      do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE);
  
*** ../vim-9.0.1570/src/popupmenu.c     2023-05-07 21:59:28.540096431 +0100
--- src/popupmenu.c     2023-05-20 13:37:03.791236637 +0100
***************
*** 865,871 ****
            ++no_u_sync;
            resized = prepare_tagpreview(FALSE, FALSE, use_popup);
            --no_u_sync;
!           --RedrawingDisabled;
            g_do_tagpreview = 0;
  
            if (curwin->w_p_pvw
--- 865,872 ----
            ++no_u_sync;
            resized = prepare_tagpreview(FALSE, FALSE, use_popup);
            --no_u_sync;
!           if (RedrawingDisabled > 0)
!               --RedrawingDisabled;
            g_do_tagpreview = 0;
  
            if (curwin->w_p_pvw
*** ../vim-9.0.1570/src/screen.c        2023-05-08 15:56:17.657756346 +0100
--- src/screen.c        2023-05-20 13:37:48.571206714 +0100
***************
*** 2696,2702 ****
  #endif
  
      entered = FALSE;
!     --RedrawingDisabled;
  
      /*
       * Do not apply autocommands more than 3 times to avoid an endless loop
--- 2696,2703 ----
  #endif
  
      entered = FALSE;
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
  
      /*
       * Do not apply autocommands more than 3 times to avoid an endless loop
***************
*** 4496,4502 ****
        return 0;
      else
  #endif
!       return ((!RedrawingDisabled
  #ifdef FEAT_EVAL
                    || ignore_redraw_flag_for_testing
  #endif
--- 4497,4503 ----
        return 0;
      else
  #endif
!       return ((RedrawingDisabled == 0
  #ifdef FEAT_EVAL
                    || ignore_redraw_flag_for_testing
  #endif
*** ../vim-9.0.1570/src/tag.c   2023-05-14 17:24:18.148997087 +0100
--- src/tag.c   2023-05-20 13:38:32.555177584 +0100
***************
*** 3829,3835 ****
        if (win_split(postponed_split > 0 ? postponed_split : 0,
                                                postponed_split_flags) == FAIL)
        {
!           --RedrawingDisabled;
            goto erret;
        }
        RESET_BINDING(curwin);
--- 3829,3836 ----
        if (win_split(postponed_split > 0 ? postponed_split : 0,
                                                postponed_split_flags) == FAIL)
        {
!           if (RedrawingDisabled > 0)
!               --RedrawingDisabled;
            goto erret;
        }
        RESET_BINDING(curwin);
***************
*** 4032,4042 ****
        }
  #endif
  
!       --RedrawingDisabled;
      }
      else
      {
!       --RedrawingDisabled;
        got_int = FALSE;  // don't want entering window to fail
  
        if (postponed_split)            // close the window
--- 4033,4045 ----
        }
  #endif
  
!       if (RedrawingDisabled > 0)
!           --RedrawingDisabled;
      }
      else
      {
!       if (RedrawingDisabled > 0)
!           --RedrawingDisabled;
        got_int = FALSE;  // don't want entering window to fail
  
        if (postponed_split)            // close the window
*** ../vim-9.0.1570/src/userfunc.c      2023-05-15 16:22:34.403075980 +0100
--- src/userfunc.c      2023-05-20 13:38:48.591167022 +0100
***************
*** 3048,3054 ****
      // Invoke functions added with ":defer".
      handle_defer_one(current_funccal);
  
!     --RedrawingDisabled;
  
      // when the function was aborted because of an error, return -1
      if ((did_emsg && (fp->uf_flags & FC_ABORT)) || rettv->v_type == 
VAR_UNKNOWN)
--- 3048,3055 ----
      // Invoke functions added with ":defer".
      handle_defer_one(current_funccal);
  
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
  
      // when the function was aborted because of an error, return -1
      if ((did_emsg && (fp->uf_flags & FC_ABORT)) || rettv->v_type == 
VAR_UNKNOWN)
*** ../vim-9.0.1570/src/window.c        2023-05-14 17:24:18.148997087 +0100
--- src/window.c        2023-05-20 13:43:32.370866446 +0100
***************
*** 950,955 ****
--- 950,959 ----
      int               minheight;
      int               wmh1;
      int               did_set_fraction = FALSE;
+     int               retval = FAIL;
+ 
+     // Do not redraw here, curwin->w_buffer may be invalid.
+     ++RedrawingDisabled;
  
      if (flags & WSP_TOP)
        oldwin = firstwin;
***************
*** 964,970 ****
        if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           return FAIL;
        }
        need_status = STATUS_HEIGHT;
      }
--- 968,974 ----
        if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           goto theend;
        }
        need_status = STATUS_HEIGHT;
      }
***************
*** 1022,1028 ****
        if (available < needed && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           return FAIL;
        }
        if (new_size == 0)
            new_size = oldwin->w_width / 2;
--- 1026,1032 ----
        if (available < needed && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           goto theend;
        }
        if (new_size == 0)
            new_size = oldwin->w_width / 2;
***************
*** 1105,1111 ****
        if (available < needed && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           return FAIL;
        }
        oldwin_height = oldwin->w_height;
        if (need_status)
--- 1109,1115 ----
        if (available < needed && new_wp == NULL)
        {
            emsg(_(e_not_enough_room));
!           goto theend;
        }
        oldwin_height = oldwin->w_height;
        if (need_status)
***************
*** 1188,1200 ****
      if (new_wp == NULL)
      {
        if (wp == NULL)
!           return FAIL;
  
        new_frame(wp);
        if (wp->w_frame == NULL)
        {
            win_free(wp, NULL);
!           return FAIL;
        }
  
        // make the contents of the new window the same as the current one
--- 1192,1204 ----
      if (new_wp == NULL)
      {
        if (wp == NULL)
!           goto theend;
  
        new_frame(wp);
        if (wp->w_frame == NULL)
        {
            win_free(wp, NULL);
!           goto theend;
        }
  
        // make the contents of the new window the same as the current one
***************
*** 1435,1442 ****
        p_wiw = i;
      else
        p_wh = i;
  
!     return OK;
  }
  
  
--- 1439,1450 ----
        p_wiw = i;
      else
        p_wh = i;
+     retval = OK;
  
! theend:
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
!     return retval;
  }
  
  
***************
*** 2460,2466 ****
                }
      }
  
!     --RedrawingDisabled;
  
      if (count != tabpage_index(NULL))
        apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
--- 2468,2475 ----
                }
      }
  
!     if (RedrawingDisabled > 0)
!       --RedrawingDisabled;
  
      if (count != tabpage_index(NULL))
        apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
*** ../vim-9.0.1570/src/version.c       2023-05-19 21:40:57.854218815 +0100
--- src/version.c       2023-05-20 13:46:04.010677254 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1571,
  /**/

-- 
The real
trick is
this: to
keep the
lines as
short as
possible
and keep
the size
the same
yet free
from the
need for
hyphena-
Dammit!!  (Matthew Winn)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230520130731.0769B1C0A8A%40moolenaar.net.

Raspunde prin e-mail lui