summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-07 18:58:59 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-07 18:58:59 +0200
commitdcb170018642ec144cd87d9d9fe076575b8d1263 (patch)
treead3a4a0cc099d8b16715822700dae3b4b616a38a /src
parent1e5e1231ac9e1ba9678812c96f9d554a078eeec4 (diff)
patch 7.4.1997v7.4.1997
Problem: Cannot easily scroll the quickfix window. Solution: Add ":cbottom".
Diffstat (limited to 'src')
-rw-r--r--src/ex_cmds.h3
-rw-r--r--src/ex_docmd.c1
-rw-r--r--src/proto/quickfix.pro1
-rw-r--r--src/quickfix.c55
-rw-r--r--src/testdir/test_quickfix.vim13
-rw-r--r--src/version.c2
6 files changed, 60 insertions, 15 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 5053e602e6..8c64d331ad 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -259,6 +259,9 @@ EX(CMD_catch, "catch", ex_catch,
EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
BANG|RANGE|NOTADR|WORD1|TRLBAR,
ADDR_LINES),
+EX(CMD_cbottom, "cbottom", ex_cbottom,
+ TRLBAR,
+ ADDR_LINES),
EX(CMD_cc, "cc", ex_cc,
RANGE|NOTADR|COUNT|TRLBAR|BANG,
ADDR_LINES),
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index ad4ba7c4e5..0be3a69102 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -129,6 +129,7 @@ static int getargopt(exarg_T *eap);
# define ex_cclose ex_ni
# define ex_copen ex_ni
# define ex_cwindow ex_ni
+# define ex_cbottom ex_ni
#endif
#if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL)
# define ex_cexpr ex_ni
diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro
index cc60eddbd2..a2b6b76cbc 100644
--- a/src/proto/quickfix.pro
+++ b/src/proto/quickfix.pro
@@ -9,6 +9,7 @@ void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long
void ex_cwindow(exarg_T *eap);
void ex_cclose(exarg_T *eap);
void ex_copen(exarg_T *eap);
+void ex_cbottom(exarg_T *eap);
linenr_T qf_current_entry(win_T *wp);
int bt_quickfix(buf_T *buf);
int bt_nofile(buf_T *buf);
diff --git a/src/quickfix.c b/src/quickfix.c
index 7bfd488051..45659a0242 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2808,6 +2808,41 @@ ex_copen(exarg_T *eap)
}
/*
+ * 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;
+#ifdef FEAT_VIRTUALEDIT
+ curwin->w_cursor.coladd = 0;
+#endif
+ 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 UNUSED)
+{
+ 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
* window).
*/
@@ -2844,27 +2879,17 @@ qf_win_pos_update(
&& qf_index <= win->w_buffer->b_ml.ml_line_count
&& old_qf_index != qf_index)
{
- win_T *old_curwin = curwin;
-
- curwin = win;
- curbuf = win->w_buffer;
if (qf_index > old_qf_index)
{
- curwin->w_redraw_top = old_qf_index;
- curwin->w_redraw_bot = qf_index;
+ win->w_redraw_top = old_qf_index;
+ win->w_redraw_bot = qf_index;
}
else
{
- curwin->w_redraw_top = qf_index;
- curwin->w_redraw_bot = old_qf_index;
+ win->w_redraw_top = qf_index;
+ win->w_redraw_bot = old_qf_index;
}
- curwin->w_cursor.lnum = 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;
+ qf_win_goto(win, qf_index);
}
return win != NULL;
}
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index d624baf80a..01e21106ed 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1414,3 +1414,16 @@ echo string(loc_two)
call delete('Xone', 'rf')
call delete('Xtwo', 'rf')
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
diff --git a/src/version.c b/src/version.c
index b6b9e59eb2..d606bab2ab 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1997,
+/**/
1996,
/**/
1995,