From 2c59277ca867cb3cb0144adedcfe05373d5498de Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 14 Dec 2016 15:33:06 -0500 Subject: vim-patch:7.4.2010 Problem: There is a :cbottom command but no :lbottom command. Solution: Add :lbottom. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d --- src/nvim/ex_cmds.lua | 6 ++++++ src/nvim/quickfix.c | 14 ++++++++++++-- src/nvim/testdir/test_quickfix.vim | 23 +++++++++++++++++------ src/nvim/version.c | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index e39e374e2e..eaf18fc664 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1271,6 +1271,12 @@ return { addr_type=ADDR_LINES, func='ex_later', }, + { + command='lbottom', + flags=bit.bor(TRLBAR), + addr_type=ADDR_LINES, + func='ex_cbottom', + }, { command='lbuffer', flags=bit.bor(BANG, RANGE, NOTADR, WORD1, TRLBAR), diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index c40b7173c5..93d0df1076 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2449,10 +2449,20 @@ static void qf_win_goto(win_T *win, linenr_T lnum) curbuf = curwin->w_buffer; } -// :cbottom command. +// :cbottom/:lbottom command. void ex_cbottom(exarg_T *eap) { - win_T *win = qf_find_win(&ql_info); + qf_info_T *qi = &ql_info; + + if (eap->cmdidx == CMD_lbottom) { + qi = GET_LOC_LIST(curwin); + if (qi == NULL) { + EMSG(_(e_loclist)); + return; + } + } + + win_T *win = qf_find_win(qi); if (win != NULL && win->w_cursor.lnum != win->w_buffer->b_ml.ml_line_count) { qf_win_goto(win, win->w_buffer->b_ml.ml_line_count); diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 7b141f17a4..f30902b915 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -15,6 +15,7 @@ function! s:setup_commands(cchar) command! -nargs=* Xnewer cnewer command! -nargs=* Xopen copen command! -nargs=* Xwindow cwindow + command! -nargs=* Xbottom cbottom command! -nargs=* Xclose cclose command! -nargs=* -bang Xfile cfile command! -nargs=* Xgetfile cgetfile @@ -44,6 +45,7 @@ function! s:setup_commands(cchar) command! -nargs=* Xnewer lnewer command! -nargs=* Xopen lopen command! -nargs=* Xwindow lwindow + command! -nargs=* Xbottom lbottom command! -nargs=* Xclose lclose command! -nargs=* -bang Xfile lfile command! -nargs=* Xgetfile lgetfile @@ -200,6 +202,7 @@ function XwindowTests(cchar) Xwindow call assert_true(winnr('$') == 2 && winnr() == 2 && \ getline('.') ==# 'Xtestfile1|1 col 3| Line1') + redraw! " Close the window Xclose @@ -1397,15 +1400,23 @@ echo string(loc_two) call delete('Xtwo', 'rf') endfunc -function Test_cbottom() - call setqflist([{'filename': 'foo', 'lnum': 42}]) - copen +function XbottomTests(cchar) + call s:setup_commands(a:cchar) + + call g:Xsetlist([{'filename': 'foo', 'lnum': 42}]) + Xopen let wid = win_getid() call assert_equal(1, line('.')) wincmd w - call setqflist([{'filename': 'var', 'lnum': 24}], 'a') - cbottom + call g:Xsetlist([{'filename': 'var', 'lnum': 24}], 'a') + Xbottom call win_gotoid(wid) call assert_equal(2, line('.')) - cclose + Xclose endfunc + +" Tests for the :cbottom and :lbottom commands +function Test_cbottom() + call XbottomTests('c') + call XbottomTests('l') +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index 9a273dd66c..512d52cbc4 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -430,7 +430,7 @@ static int included_patches[] = { 2013, 2012, 2011, - // 2010, + 2010, // 2009, // 2008, 2007, -- cgit