patch 7.1.068

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

patch 7.1.068

Bram Moolenaar


Patch 7.1.068
Problem:    When 'equalalways' is set and splitting a window, it's possible
            that another small window gets bigger.
Solution:   Only equalize window sizes when after a split the windows are
            smaller than another window. (Martin Toft)
Files:    runtime/doc/options.txt, runtime/doc/windows.txt, src/window.c


*** ../vim-7.1.067/runtime/doc/options.txt Sat May 12 16:27:04 2007
--- runtime/doc/options.txt Sat Aug 11 17:25:38 2007
***************
*** 1,4 ****
! *options.txt* For Vim version 7.1.  Last change: 2007 May 11
 
 
   VIM REFERENCE MANUAL  by Bram Moolenaar
--- 1,4 ----
! *options.txt* For Vim version 7.1.  Last change: 2007 Aug 10
 
 
   VIM REFERENCE MANUAL  by Bram Moolenaar
***************
*** 2415,2422 ****
  When mixing vertically and horizontally split windows, a minimal size
  is computed and some windows may be larger if there is room.  The
  'eadirection' option tells in which direction the size is affected.
! Changing the height of a window can be avoided by setting
! 'winfixheight'.
 
  *'equalprg'* *'ep'*
  'equalprg' 'ep' string (default "")
--- 2418,2425 ----
  When mixing vertically and horizontally split windows, a minimal size
  is computed and some windows may be larger if there is room.  The
  'eadirection' option tells in which direction the size is affected.
! Changing the height and width of a window can be avoided by setting
! 'winfixheight' and 'winfixwidth', respectively.
 
  *'equalprg'* *'ep'*
  'equalprg' 'ep' string (default "")
*** ../vim-7.1.067/runtime/doc/windows.txt Sat May 12 16:42:48 2007
--- runtime/doc/windows.txt Sat Aug 11 17:25:38 2007
***************
*** 132,138 ****
  the same file.  Make new window N high (default is to use half
  the height of the current window).  Reduces the current window
  height to create room (and others, if the 'equalalways' option
! is set and 'eadirection' isn't "hor").
  Note: CTRL-S does not work on all terminals and might block
  further input, use CTRL-Q to get going again.
  Also see |++opt| and |+cmd|.
--- 132,139 ----
  the same file.  Make new window N high (default is to use half
  the height of the current window).  Reduces the current window
  height to create room (and others, if the 'equalalways' option
! is set, 'eadirection' isn't "hor", and one of them is higher
! than the current or the new window).
  Note: CTRL-S does not work on all terminals and might block
  further input, use CTRL-Q to get going again.
  Also see |++opt| and |+cmd|.
***************
*** 140,148 ****
  CTRL-W CTRL-V *CTRL-W_CTRL-V*
  CTRL-W v *CTRL-W_v*
  :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit*
! Like |:split|, but split vertically.  If 'equalalways' is set
! and 'eadirection' isn't "ver" the windows will be spread out
! horizontally, unless a width was specified.
  Note: In other places CTRL-Q does the same as CTRL-V, but here
  it doesn't!
 
--- 141,153 ----
  CTRL-W CTRL-V *CTRL-W_CTRL-V*
  CTRL-W v *CTRL-W_v*
  :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit*
! Like |:split|, but split vertically.  The windows will be
! spread out horizontally if
! 1. a width was not specified,
! 2. 'equalalways' is set,
! 3. 'eadirection' isn't "ver", and
! 4. one of the other windows are wider than the current or new
!   window.
  Note: In other places CTRL-Q does the same as CTRL-V, but here
  it doesn't!
 
*** ../vim-7.1.067/src/window.c Sat Aug 11 13:37:36 2007
--- src/window.c Sat Aug 11 17:25:38 2007
***************
*** 733,739 ****
      if (flags & WSP_VERT)
      {
  layout = FR_ROW;
- do_equal = (p_ea && new_size == 0 && *p_ead != 'v');
 
  /*
  * Check if we are able to split the current window and compute its
--- 733,738 ----
***************
*** 770,785 ****
  * instead, if possible. */
  if (oldwin->w_p_wfw)
     win_setwidth_win(oldwin->w_width + new_size, oldwin);
      }
      else
  #endif
      {
  layout = FR_COL;
- do_equal = (p_ea && new_size == 0
- #ifdef FEAT_VERTSPLIT
- && *p_ead != 'h'
- #endif
- );
 
  /*
  * Check if we are able to split the current window and compute its
--- 769,799 ----
  * instead, if possible. */
  if (oldwin->w_p_wfw)
     win_setwidth_win(oldwin->w_width + new_size, oldwin);
+
+ /* Only make all windows the same width if one of them (except oldwin)
+ * is wider than one of the split windows. */
+ if (!do_equal && p_ea && size == 0 && *p_ead != 'v'
+   && oldwin->w_frame->fr_parent != NULL)
+ {
+    frp = oldwin->w_frame->fr_parent->fr_child;
+    while (frp != NULL)
+    {
+ if (frp->fr_win != oldwin && frp->fr_win != NULL
+ && (frp->fr_win->w_width > new_size
+    || frp->fr_win->w_width > oldwin->w_width
+   - new_size - STATUS_HEIGHT))
+ {
+    do_equal = TRUE;
+    break;
+ }
+ frp = frp->fr_next;
+    }
+ }
      }
      else
  #endif
      {
  layout = FR_COL;
 
  /*
  * Check if we are able to split the current window and compute its
***************
*** 831,836 ****
--- 845,873 ----
     oldwin_height = oldwin->w_height;
     if (need_status)
  oldwin_height -= STATUS_HEIGHT;
+ }
+
+ /* Only make all windows the same height if one of them (except oldwin)
+ * is higher than one of the split windows. */
+ if (!do_equal && p_ea && size == 0
+ #ifdef FEAT_VERTSPLIT
+ && *p_ead != 'h'
+ #endif
+   && oldwin->w_frame->fr_parent != NULL)
+ {
+    frp = oldwin->w_frame->fr_parent->fr_child;
+    while (frp != NULL)
+    {
+ if (frp->fr_win != oldwin && frp->fr_win != NULL
+ && (frp->fr_win->w_height > new_size
+    || frp->fr_win->w_height > oldwin_height - new_size
+      - STATUS_HEIGHT))
+ {
+    do_equal = TRUE;
+    break;
+ }
+ frp = frp->fr_next;
+    }
  }
      }
 
*** ../vim-7.1.067/src/version.c Sun Aug 12 16:38:03 2007
--- src/version.c Sun Aug 12 16:51:36 2007
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     68,
  /**/

--
hundred-and-one symptoms of being an internet addict:
129. You cancel your newspaper subscription.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Tony Mechelynck

Bram Moolenaar wrote:
>
> Patch 7.1.068
> Problem:    When 'equalalways' is set and splitting a window, it's possible
>    that another small window gets bigger.
> Solution:   Only equalize window sizes when after a split the windows are
>    smaller than another window. (Martin Toft)
> Files:    runtime/doc/options.txt, runtime/doc/windows.txt, src/window.c
[...]

I guess there's something I don't understand.

Let's say 'equalalways' is set and I've used Ctrl-W _ to temporarily make the
current window full-size, squashing all windows above and below it to
'winminheight' (which I have set to zero in my vimrc).

If I create or delete a window (e.g. with ":split") I would expect
'equalalways' to come into play, and redraw all windows to the same size
(growing small windows and shrinking the current big one and its new child).

This is in accord with how I understand the current (2007 Jul 11) help for
'equalalways'.

What is wrong in my way of thinking?


Best regards,
Tony.
--
It is illegal for anyone to give lighted cigars to dogs, cats, and other
domesticated animal kept as pets.
                [real standing law in Illinois, United States of America]

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Bram Moolenaar


Tony Mechelynck wrote:

> Bram Moolenaar wrote:
> >
> > Patch 7.1.068
> > Problem:    When 'equalalways' is set and splitting a window, it's possible
> >    that another small window gets bigger.
> > Solution:   Only equalize window sizes when after a split the windows are
> >    smaller than another window. (Martin Toft)
> > Files:    runtime/doc/options.txt, runtime/doc/windows.txt, src/window.c
> [...]
>
> I guess there's something I don't understand.
>
> Let's say 'equalalways' is set and I've used Ctrl-W _ to temporarily make the
> current window full-size, squashing all windows above and below it to
> 'winminheight' (which I have set to zero in my vimrc).
>
> If I create or delete a window (e.g. with ":split") I would expect
> 'equalalways' to come into play, and redraw all windows to the same size
> (growing small windows and shrinking the current big one and its new child).
>
> This is in accord with how I understand the current (2007 Jul 11) help for
> 'equalalways'.
>
> What is wrong in my way of thinking?

If you make the current window use the maximum available space, and then
do ":split", don't you expect the two windows, the current one and the
new one, to occupy the same space?  That is what I expect.

The 'equalalways' option has the intention to spread out the available
space, so that when you ":split" you can use the space from other
windows.  But when the space from the current window is sufficient that
is not needed.  That is what this patch fixes.

Another situation: I often have a window open to a file where I add
remarks.  This only needs to be a few lines tall.  When I split the main
window this other window is suddenly made a lot bigger, and I have to
resize it again.  After this patch it works as I would expect.

Obviously it still isn't perfect, when closing a window the
intentionally small window still gets bigger.  Vim can't know you don't
want this window to get some of the newly available space.  A more
advanced solution could perhaps resize proportionally.  But it's
probably very difficult to make that work well, considering windows can
be split horizontally and vertically to make very complex window
layouts.

--
hundred-and-one symptoms of being an internet addict:
130. You can't get out of your desk even if it's time to eat or time
     to go to the bathroom.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Martin Toft
In reply to this post by Tony Mechelynck
On Sun, Aug 12, 2007 at 05:10:13PM +0200, Tony Mechelynck wrote:

> Bram Moolenaar wrote:
> > Patch 7.1.068
> > Problem: When 'equalalways' is set and splitting a window, it's
> >          possible that another small window gets bigger.
> > Solution: Only equalize window sizes when after a split the
> >           windows are smaller than another window. (Martin Toft)
> > Files: runtime/doc/options.txt, runtime/doc/windows.txt,
> >        src/window.c
> [...]
>
> I guess there's something I don't understand.
>
> Let's say 'equalalways' is set and I've used Ctrl-W _ to temporarily
> make the current window full-size, squashing all windows above and
> below it to 'winminheight' (which I have set to zero in my vimrc).
>
> If I create or delete a window (e.g. with ":split") I would expect
> 'equalalways' to come into play, and redraw all windows to the same
> size (growing small windows and shrinking the current big one and its
> new child).
>
> This is in accord with how I understand the current (2007 Jul 11) help
> for 'equalalways'.
>
> What is wrong in my way of thinking?
I must admit that I was also a bit confused while writing the patch (and
still am).  The documentation for 'equalalways' is straight forward: all
windows are automatically made the same size after splitting or closing
a window.  My patch changes the behaviour of 'equalalways' when
splitting a window, and I therefore changed the documentation for
":split", not for 'equalalways'.

The bug report has apparently been submitted due to one or more people
being annoyed by 'equalalways' making small windows bigger.  I was asked
by Bram to do the patch, as I had just gotten familiar with Vim's window
handling code from writing another patch.

Without the new behaviour introduced by this patch, it is not impossible
to avoid small windows being made bigger by 'equalalways' --
'winfixheight' and 'winfixwidth' can be used for this.  Consequently,
the patch doesn't add anything that wasn't possible before.

I don't know exactly what my opion is about the patch, as I'm not a Vim
power user and I don't know what is the general understanding of
'equalalways' is.  The subject is quite debateable.

Martin

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Tony Mechelynck
In reply to this post by Bram Moolenaar

Bram Moolenaar wrote:

> Tony Mechelynck wrote:
>
>> Bram Moolenaar wrote:
>>> Patch 7.1.068
>>> Problem:    When 'equalalways' is set and splitting a window, it's possible
>>>    that another small window gets bigger.
>>> Solution:   Only equalize window sizes when after a split the windows are
>>>    smaller than another window. (Martin Toft)
>>> Files:    runtime/doc/options.txt, runtime/doc/windows.txt, src/window.c
>> [...]
>>
>> I guess there's something I don't understand.
>>
>> Let's say 'equalalways' is set and I've used Ctrl-W _ to temporarily make the
>> current window full-size, squashing all windows above and below it to
>> 'winminheight' (which I have set to zero in my vimrc).
>>
>> If I create or delete a window (e.g. with ":split") I would expect
>> 'equalalways' to come into play, and redraw all windows to the same size
>> (growing small windows and shrinking the current big one and its new child).
>>
>> This is in accord with how I understand the current (2007 Jul 11) help for
>> 'equalalways'.
>>
>> What is wrong in my way of thinking?
>
> If you make the current window use the maximum available space, and then
> do ":split", don't you expect the two windows, the current one and the
> new one, to occupy the same space?  That is what I expect.

no, if I use ^W_ with 'equalalways' set, it is temporary. If after that I use
":split", ":new", ":sview", ":q", ":x", or anything that changes the number of
windows, then poof! they are all equal again. That's how Vim has always
behaved, and I thought it was the normal behaviour. If I wanted my windows to
stay unequal for any length of time, I would set 'noequalalways'.

>
> The 'equalalways' option has the intention to spread out the available
> space, so that when you ":split" you can use the space from other
> windows.  But when the space from the current window is sufficient that
> is not needed.  That is what this patch fixes.

The way I understood the help (and, until now, experiment bore me out) was
that 'equalalways' was meant to make all windows "always equal", except that
you could temporarily change window sizes. But such changes would not persist
over a window-creation or -deletion, as long as 'equalalways' was on.

>
> Another situation: I often have a window open to a file where I add
> remarks.  This only needs to be a few lines tall.  When I split the main
> window this other window is suddenly made a lot bigger, and I have to
> resize it again.  After this patch it works as I would expect.

If you want one window to be (and remain) a different size than all others,
then leave 'equalalways' off. Or maybe use ":setlocal winfixheight".

This patch breaks age-old documented behaviour -- documented under
'equalalways' and maybe elsewhere: here is the 'equalalways' text:

        When on, all the windows are automatically made the same size after
        splitting or closing a window.  This also happens the moment the
        option is switched on.  When off, [...]


>
> Obviously it still isn't perfect, when closing a window the
> intentionally small window still gets bigger.  Vim can't know you don't
> want this window to get some of the newly available space.  A more
> advanced solution could perhaps resize proportionally.  But it's
> probably very difficult to make that work well, considering windows can
> be split horizontally and vertically to make very complex window
> layouts.
>


Best regards,
Tony.
--
All wars are civil wars, because all men are brothers ... Each one owes
infinitely more to the human race than to the particular country in
which he was born.
                -- Francois Fenelon

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Matthew Winn-3
In reply to this post by Bram Moolenaar

On Sun, 12 Aug 2007 17:41:21 +0200, Bram Moolenaar
<[hidden email]> wrote:

> The 'equalalways' option has the intention to spread out the available
> space, so that when you ":split" you can use the space from other
> windows.  But when the space from the current window is sufficient that
> is not needed.  That is what this patch fixes.
>
> Another situation: I often have a window open to a file where I add
> remarks.  This only needs to be a few lines tall.  When I split the main
> window this other window is suddenly made a lot bigger, and I have to
> resize it again.  After this patch it works as I would expect.

I use a similar layout. Sometimes I'll have a header file open in a
separate window so I can rapidly check the names of flags or fields,
but I like to keep that window small: perhaps four lines. I've never
been happy with the way equalalways worked because with it on it
wrecked my small window every time I split the main window, and with
it off three successive splits mean I'm left working in an eighth of
the available space instead of a quarter: typically four lines in the
active window instead of the nine I'd get with an equal distribution.

--
Matthew Winn

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

RE: patch 7.1.068

Suresh Govindachar`

 
  Bram Moolenaar wrote:

  > The 'equalalways' option has the intention to spread out the
  > available space, so that when you ":split" you can use the space
  > from other windows. But when the space from the current window
  > is sufficient that is not needed. That is what this patch fixes.
  >
  > Another situation: I often have a window open to a file where I
  > add remarks. This only needs to be a few lines tall. When I
  > split the main window this other window is suddenly made a lot
  > bigger, and I have to resize it again. After this patch it works
  > as I would expect.

  Although I think Tony is correct in his interpretation of the
  :help on equalalways, I too have never been happy with the way it
  worked.  I prefer this new not-really-equal-equalalways.  Perhaps
  this patch should support a 'pseudoeuqalalways' option?

  --Suresh



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Matthew Winn-3

On Mon, 13 Aug 2007 06:58:02 -0700, "Suresh Govindachar`"
<[hidden email]> wrote:

> Although I think Tony is correct in his interpretation of the
> :help on equalalways, I too have never been happy with the way it
> worked.  I prefer this new not-really-equal-equalalways.  Perhaps
> this patch should support a 'pseudoeuqalalways' option?

:set equalmostly?

--
Matthew Winn

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Milan Vancura

>
> On Mon, 13 Aug 2007 06:58:02 -0700, "Suresh Govindachar`"
> <[hidden email]> wrote:
>
> > Although I think Tony is correct in his interpretation of the
> > :help on equalalways, I too have never been happy with the way it
> > worked.  I prefer this new not-really-equal-equalalways.  Perhaps
> > this patch should support a 'pseudoeuqalalways' option?
>
> :set equalmostly?

:splitin

splitin does the same as :split does, but doesn't change sizes of other
windows, just splits the actual one and uses the area of actual one for both
this and the new one.


Milan Vancura

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Adri Verhoef
In reply to this post by Bram Moolenaar

On Sun, Aug 12, 2007 at 14:55:48 +0000, Bram Moolenaar wrote:
> Patch 7.1.068
> --- runtime/doc/options.txt Sat Aug 11 17:25:38 2007
> ! 4. one of the other windows are wider than the current or new
> !   window.

Should be: ...one of the other windows is wider...
                                       ^^
Adri

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: patch 7.1.068

Bram Moolenaar


Adri Verhoef wrote:

> On Sun, Aug 12, 2007 at 14:55:48 +0000, Bram Moolenaar wrote:
> > Patch 7.1.068
> > --- runtime/doc/options.txt Sat Aug 11 17:25:38 2007
> > ! 4. one of the other windows are wider than the current or new
> > !   window.
>
> Should be: ...one of the other windows is wider...

Thanks.  But it's in windows.txt, not in options.txt.

--
hundred-and-one symptoms of being an internet addict:
162. You go outside and look for a brightness knob to turn down the sun.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---