Hi Bram,

On Mon, Dec 25, 2017 at 2:24 PM, Bram Moolenaar <[email protected]> wrote:
>
> Yegappan wrote:
>
>> On Mon, Dec 25, 2017 at 7:51 AM, lacygoill <[email protected]> wrote:
>> > To reproduce:
>> >
>> > vim -Nu NONE some_file
>> > :vim /./ %
>> > :leftabove copen
>> >
>> > I expected the window to be opened on the left, but instead Vim opens it on
>> > the right.
>> >
>> > According to :h :lefta:
>> >
>> > Doesn't work for |:execute| and |:normal|.
>> >
>> > So, I thought that maybe :leftabove doesn't work with :copen, like for
>> > :execute and :normal.
>> > But this remark is also present in :h :topleft and :h :botright, which
>> > doesn't prevent these modifiers to work with :copen:
>> >
>> > :bo copen
>> >
>> > Opens the quickfix window at the very bottom of the screen.
>> >
>> > :to copen
>> >
>> > Opens the quickfix window at the very top of the screen.
>> >
>> > I searched on the issue tracker (is:issue leftabove, is:issue aboveleft,
>> > is:issue belowright, is:issue rightbelow) but couldn't find anything which
>> > seemed relevant.
>> >
>>
>> I am attaching a patch to do this. But I am not sure whether this behavior is
>> acceptable/expected. If you open the quickfix/location window in a vertically
>> split window, it is hard to read the lines. As the quickfix/location windows 
>> has
>> long lines, from a readability perspective, it makes sense to open it always 
>> as
>> a horizontally split window (either at the top or at the bottom).
>
> Thanks for the patch.  However, I don't think it should change
> cmdmod.split, that's an unexpected side effect.  Using a local variable
> would be better.
>

Agreed.

>
> It may be strange to do a vertical split, but if the screen is very wide
> it does make sense.
>
> Would be nice to have a test.
>

I am attaching an updated patch with a test.

While writing the test, I realized that currently it is not possible to get
the position of a window in the layout. It is not possible to check whether
a window is vertically or horizontally split and occupies multiple window rows
or columns.

- Yegappan

-- 
-- 
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 --git a/src/quickfix.c b/src/quickfix.c
index 05e594628..8e745213a 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3222,6 +3222,8 @@ ex_copen(exarg_T *eap)
     }
     else
     {
+       int flags = 0;
+
        qf_buf = qf_find_buf(qi);
 
        /* The current window becomes the previous window afterwards. */
@@ -3229,10 +3231,14 @@ ex_copen(exarg_T *eap)
 
        if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
                && cmdmod.split == 0)
-           /* Create the new window at the very bottom, except when
+           /* Create the new quickfix window at the very bottom, except when
             * :belowright or :aboveleft is used. */
            win_goto(lastwin);
-       if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
+       /* Default is to open the window below the current window */
+       if (cmdmod.split == 0)
+           flags = WSP_BELOW;
+       flags |= WSP_NEWLOC;
+       if (win_split(height, flags) == FAIL)
            return;             /* not enough room for window */
        RESET_BINDING(curwin);
 
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 0787e60e3..fb78f6983 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -3078,3 +3078,30 @@ func Test_lvimgrep_crash()
   augroup END
   enew | only
 endfunc
+
+" Test for the position of the quickfix and location list window
+func Test_qfwin_pos()
+  " Open two windows
+  new | only
+  new
+  cexpr ['F1:10:L10']
+  copen
+  " Quickfix window should be the bottom most window
+  call assert_equal(3, winnr())
+  close
+  " Open at the very top
+  wincmd t
+  topleft copen
+  call assert_equal(1, winnr())
+  close
+  " open left of the current window
+  wincmd t
+  below new
+  leftabove copen
+  call assert_equal(2, winnr())
+  close
+  " open right of the current window
+  rightbelow copen
+  call assert_equal(3, winnr())
+  close
+endfunc

Raspunde prin e-mail lui