":botright split" create window with invalid size when there is only a few
spaces.

Steps to reproduce:

  $ vim -u NONE -N
  :vsplit
  :while 1 | split | endwhile
  :quit
  :botright split
  :echo winheight(0)
  11                    (actual height is 2 or 3)
  o<CR><CR><CR><CR><CR><CR><CR><CR><CR><CR><CR>....   (editing buffer may
cause crash)
  Vim: Caught deadly signal SEGV

  It is same with ":botright vsplit"

  $ vim -u NONE -N
  :split
  :while 1 | vsplit | endwhile
  :quit
  :botright vsplit
  :echo winheight(0)
  40                    (actual width is 2 or 3)

Please check the attached patch.

-- 
Yukihiro Nakadaira - [email protected]

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.
diff -r 0efec12f52ac src/window.c
--- a/src/window.c      Thu Jul 10 22:01:47 2014 +0200
+++ b/src/window.c      Tue Jul 15 23:07:51 2014 +0900
@@ -686,6 +686,8 @@
     int                layout;
     frame_T    *frp, *curfrp;
     int                before;
+    int                minwidth;
+    int                minheight;
 
     if (flags & WSP_TOP)
        oldwin = firstwin;
@@ -725,11 +727,15 @@
            needed += p_wiw - p_wmw;
        if (p_ea || (flags & (WSP_BOT | WSP_TOP)))
        {
+           minwidth = frame_minwidth(topframe, NULL);
            available = topframe->fr_width;
-           needed += frame_minwidth(topframe, NULL);
+           needed += minwidth;
        }
        else
+       {
+           minwidth = frame_minwidth(oldwin->w_frame, NULL);
            available = oldwin->w_width;
+       }
        if (available < needed && new_wp == NULL)
        {
            EMSG(_(e_noroom));
@@ -739,6 +745,8 @@
            new_size = oldwin->w_width / 2;
        if (new_size > oldwin->w_width - p_wmw - 1)
            new_size = oldwin->w_width - p_wmw - 1;
+       if (new_size > available - minwidth - 1)
+           new_size = available - minwidth - 1;
        if (new_size < p_wmw)
            new_size = p_wmw;
 
@@ -786,11 +794,13 @@
            needed += p_wh - p_wmh;
        if (p_ea || (flags & (WSP_BOT | WSP_TOP)))
        {
+           minheight = frame_minheight(topframe, NULL);
            available = topframe->fr_height;
-           needed += frame_minheight(topframe, NULL);
+           needed += minheight;
        }
        else
        {
+           minheight = frame_minheight(oldwin->w_frame, NULL);
            available = oldwin->w_height;
            needed += p_wmh;
        }
@@ -810,6 +820,8 @@
 
        if (new_size > oldwin_height - p_wmh - STATUS_HEIGHT)
            new_size = oldwin_height - p_wmh - STATUS_HEIGHT;
+       if (new_size > available - minheight - STATUS_HEIGHT)
+           new_size = available - minheight - STATUS_HEIGHT;
        if (new_size < p_wmh)
            new_size = p_wmh;
 

Raspunde prin e-mail lui