mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.1997
Problem: Cannot easily scroll the quickfix window.
Solution: Add ":cbottom".
dcb1700186
This commit is contained in:
parent
f613c61dae
commit
f224f3fbf1
@ -428,6 +428,12 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
|
|||||||
:lw[indow] [height] Same as ":cwindow", except use the window showing the
|
:lw[indow] [height] Same as ":cwindow", except use the window showing the
|
||||||
location list for the current window.
|
location list for the current window.
|
||||||
|
|
||||||
|
:cbo[ttom] Put the cursor in the last line of the quickfix window
|
||||||
|
and scroll to make it visible. This is useful for
|
||||||
|
when errors are added by an asynchronous callback.
|
||||||
|
Only call it once in a while if there are many
|
||||||
|
updates to avoid a lot of redrawing.
|
||||||
|
|
||||||
Normally the quickfix window is at the bottom of the screen. If there are
|
Normally the quickfix window is at the bottom of the screen. If there are
|
||||||
vertical splits, it's at the bottom of the rightmost column of windows. To
|
vertical splits, it's at the bottom of the rightmost column of windows. To
|
||||||
make it always occupy the full width: >
|
make it always occupy the full width: >
|
||||||
|
@ -357,6 +357,12 @@ return {
|
|||||||
addr_type=ADDR_LINES,
|
addr_type=ADDR_LINES,
|
||||||
func='ex_cbuffer',
|
func='ex_cbuffer',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
command='cbottom',
|
||||||
|
flags=bit.bor(TRLBAR),
|
||||||
|
addr_type=ADDR_LINES,
|
||||||
|
func='ex_cbottom',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
command='cc',
|
command='cc',
|
||||||
flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR, BANG),
|
flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR, BANG),
|
||||||
|
@ -2431,6 +2431,34 @@ void ex_copen(exarg_T *eap)
|
|||||||
update_topline(); /* scroll to show the line */
|
update_topline(); /* scroll to show the line */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move the cursor in the quickfix window to "lnum".
|
||||||
|
static void qf_win_goto(win_T *win, linenr_T lnum)
|
||||||
|
{
|
||||||
|
win_T *old_curwin = curwin;
|
||||||
|
|
||||||
|
curwin = win;
|
||||||
|
curbuf = win->w_buffer;
|
||||||
|
curwin->w_cursor.lnum = lnum;
|
||||||
|
curwin->w_cursor.col = 0;
|
||||||
|
curwin->w_cursor.coladd = 0;
|
||||||
|
curwin->w_curswant = 0;
|
||||||
|
update_topline(); // scroll to show the line
|
||||||
|
redraw_later(VALID);
|
||||||
|
curwin->w_redr_status = true; // update ruler
|
||||||
|
curwin = old_curwin;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// :cbottom command.
|
||||||
|
void ex_cbottom(exarg_T *eap)
|
||||||
|
{
|
||||||
|
win_T *win = qf_find_win(&ql_info);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the number of the current entry (line number in the quickfix
|
* Return the number of the current entry (line number in the quickfix
|
||||||
* window).
|
* window).
|
||||||
@ -2467,24 +2495,14 @@ qf_win_pos_update (
|
|||||||
if (win != NULL
|
if (win != NULL
|
||||||
&& qf_index <= win->w_buffer->b_ml.ml_line_count
|
&& qf_index <= win->w_buffer->b_ml.ml_line_count
|
||||||
&& old_qf_index != qf_index) {
|
&& old_qf_index != qf_index) {
|
||||||
win_T *old_curwin = curwin;
|
|
||||||
|
|
||||||
curwin = win;
|
|
||||||
curbuf = win->w_buffer;
|
|
||||||
if (qf_index > old_qf_index) {
|
if (qf_index > old_qf_index) {
|
||||||
curwin->w_redraw_top = old_qf_index;
|
win->w_redraw_top = old_qf_index;
|
||||||
curwin->w_redraw_bot = qf_index;
|
win->w_redraw_bot = qf_index;
|
||||||
} else {
|
} else {
|
||||||
curwin->w_redraw_top = qf_index;
|
win->w_redraw_top = qf_index;
|
||||||
curwin->w_redraw_bot = old_qf_index;
|
win->w_redraw_bot = old_qf_index;
|
||||||
}
|
}
|
||||||
curwin->w_cursor.lnum = qf_index;
|
qf_win_goto(win, qf_index);
|
||||||
curwin->w_cursor.col = 0;
|
|
||||||
update_topline(); /* scroll to show the line */
|
|
||||||
redraw_later(VALID);
|
|
||||||
curwin->w_redr_status = TRUE; /* update ruler */
|
|
||||||
curwin = old_curwin;
|
|
||||||
curbuf = curwin->w_buffer;
|
|
||||||
}
|
}
|
||||||
return win != NULL;
|
return win != NULL;
|
||||||
}
|
}
|
||||||
|
@ -1396,3 +1396,16 @@ echo string(loc_two)
|
|||||||
call delete('Xone', 'rf')
|
call delete('Xone', 'rf')
|
||||||
call delete('Xtwo', 'rf')
|
call delete('Xtwo', 'rf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
function Test_cbottom()
|
||||||
|
call setqflist([{'filename': 'foo', 'lnum': 42}])
|
||||||
|
copen
|
||||||
|
let wid = win_getid()
|
||||||
|
call assert_equal(1, line('.'))
|
||||||
|
wincmd w
|
||||||
|
call setqflist([{'filename': 'var', 'lnum': 24}], 'a')
|
||||||
|
cbottom
|
||||||
|
call win_gotoid(wid)
|
||||||
|
call assert_equal(2, line('.'))
|
||||||
|
cclose
|
||||||
|
endfunc
|
||||||
|
@ -443,7 +443,7 @@ static int included_patches[] = {
|
|||||||
// 2000,
|
// 2000,
|
||||||
// 1999,
|
// 1999,
|
||||||
// 1998 NA
|
// 1998 NA
|
||||||
// 1997,
|
1997,
|
||||||
// 1996,
|
// 1996,
|
||||||
// 1995 NA
|
// 1995 NA
|
||||||
// 1994,
|
// 1994,
|
||||||
|
Loading…
Reference in New Issue
Block a user