Skip to content

Commit

Permalink
patch 8.1.1256: cannot navigate through errors relative to the cursor
Browse files Browse the repository at this point in the history
Problem:    Cannot navigate through errors relative to the cursor.
Solution:   Add :cabove, :cbelow, :labove and :lbelow. (Yegappan Lakshmanan,
            closes #4316)
  • Loading branch information
brammool committed May 3, 2019
1 parent 12e9186 commit 3ff3311
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 29 deletions.
4 changes: 4 additions & 0 deletions runtime/doc/index.txt
Expand Up @@ -1188,11 +1188,13 @@ tag command action ~
|:cNfile| :cNf[ile] go to last error in previous file |:cNfile| :cNf[ile] go to last error in previous file
|:cabbrev| :ca[bbrev] like ":abbreviate" but for Command-line mode |:cabbrev| :ca[bbrev] like ":abbreviate" but for Command-line mode
|:cabclear| :cabc[lear] clear all abbreviations for Command-line mode |:cabclear| :cabc[lear] clear all abbreviations for Command-line mode
|:cabove| :cabo[ve] go to error above current line
|:caddbuffer| :cad[dbuffer] add errors from buffer |:caddbuffer| :cad[dbuffer] add errors from buffer
|:caddexpr| :cadde[xpr] add errors from expr |:caddexpr| :cadde[xpr] add errors from expr
|:caddfile| :caddf[ile] add error message to current quickfix list |:caddfile| :caddf[ile] add error message to current quickfix list
|:call| :cal[l] call a function |:call| :cal[l] call a function
|:catch| :cat[ch] part of a :try command |:catch| :cat[ch] part of a :try command
|:cbelow| :cbe[low] got to error below current line
|:cbottom| :cbo[ttom] scroll to the bottom of the quickfix window |:cbottom| :cbo[ttom] scroll to the bottom of the quickfix window
|:cbuffer| :cb[uffer] parse error messages and jump to first error |:cbuffer| :cb[uffer] parse error messages and jump to first error
|:cc| :cc go to specific error |:cc| :cc go to specific error
Expand Down Expand Up @@ -1350,12 +1352,14 @@ tag command action ~
|:lNext| :lN[ext] go to previous entry in location list |:lNext| :lN[ext] go to previous entry in location list
|:lNfile| :lNf[ile] go to last entry in previous file |:lNfile| :lNf[ile] go to last entry in previous file
|:list| :l[ist] print lines |:list| :l[ist] print lines
|:labove| :lab[ove] go to location above current line
|:laddexpr| :lad[dexpr] add locations from expr |:laddexpr| :lad[dexpr] add locations from expr
|:laddbuffer| :laddb[uffer] add locations from buffer |:laddbuffer| :laddb[uffer] add locations from buffer
|:laddfile| :laddf[ile] add locations to current location list |:laddfile| :laddf[ile] add locations to current location list
|:last| :la[st] go to the last file in the argument list |:last| :la[st] go to the last file in the argument list
|:language| :lan[guage] set the language (locale) |:language| :lan[guage] set the language (locale)
|:later| :lat[er] go to newer change, redo |:later| :lat[er] go to newer change, redo
|:lbelow| :lbe[low] go to location below current line
|:lbottom| :lbo[ttom] scroll to the bottom of the location window |:lbottom| :lbo[ttom] scroll to the bottom of the location window
|:lbuffer| :lb[uffer] parse locations and jump to first location |:lbuffer| :lb[uffer] parse locations and jump to first location
|:lcd| :lc[d] change directory locally |:lcd| :lc[d] change directory locally
Expand Down
30 changes: 30 additions & 0 deletions runtime/doc/quickfix.txt
Expand Up @@ -123,6 +123,36 @@ processing a quickfix or location list command, it will be aborted.
list for the current window is used instead of the list for the current window is used instead of the
quickfix list. quickfix list.


*:cabo* *:cabove*
:[count]cabo[ve] Go to the [count] error above the current line in the
current buffer. If [count] is omitted, then 1 is
used. If there are no errors, then an error message
is displayed. Assumes that the entries in a quickfix
list are sorted by their buffer number and line
number. If there are multiple errors on the same line,
then only the first entry is used. If [count] exceeds
the number of entries above the current line, then the
first error in the file is selected.

*:lab* *:labove*
:[count]lab[ove] Same as ":cabove", except the location list for the
current window is used instead of the quickfix list.

*:cbe* *:cbelow*
:[count]cbe[low] Go to the [count] error below the current line in the
current buffer. If [count] is omitted, then 1 is
used. If there are no errors, then an error message
is displayed. Assumes that the entries in a quickfix
list are sorted by their buffer number and line
number. If there are multiple errors on the same
line, then only the first entry is used. If [count]
exceeds the number of entries below the current line,
then the last error in the file is selected.

*:lbe* *:lbelow*
:[count]lbe[low] Same as ":cbelow", except the location list for the
current window is used instead of the quickfix list.

*:cnf* *:cnfile* *:cnf* *:cnfile*
:[count]cnf[ile][!] Display the first error in the [count] next file in :[count]cnf[ile][!] Display the first error in the [count] next file in
the list that includes a file name. If there are no the list that includes a file name. If there are no
Expand Down
52 changes: 26 additions & 26 deletions src/ex_cmdidxs.h
Expand Up @@ -8,29 +8,29 @@ static const unsigned short cmdidxs1[26] =
/* a */ 0, /* a */ 0,
/* b */ 19, /* b */ 19,
/* c */ 42, /* c */ 42,
/* d */ 103, /* d */ 105,
/* e */ 125, /* e */ 127,
/* f */ 145, /* f */ 147,
/* g */ 161, /* g */ 163,
/* h */ 167, /* h */ 169,
/* i */ 176, /* i */ 178,
/* j */ 194, /* j */ 196,
/* k */ 196, /* k */ 198,
/* l */ 201, /* l */ 203,
/* m */ 259, /* m */ 263,
/* n */ 277, /* n */ 281,
/* o */ 297, /* o */ 301,
/* p */ 309, /* p */ 313,
/* q */ 348, /* q */ 352,
/* r */ 351, /* r */ 355,
/* s */ 371, /* s */ 375,
/* t */ 439, /* t */ 443,
/* u */ 484, /* u */ 488,
/* v */ 495, /* v */ 499,
/* w */ 513, /* w */ 517,
/* x */ 527, /* x */ 531,
/* y */ 536, /* y */ 540,
/* z */ 537 /* z */ 541
}; };


/* /*
Expand All @@ -43,7 +43,7 @@ static const unsigned char cmdidxs2[26][26] =
{ /* a b c d e f g h i j k l m n o p q r s t u v w x y z */ { /* a b c d e f g h i j k l m n o p q r s t u v w x y z */
/* a */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 15, 0, 16, 0, 0, 0, 0, 0 }, /* a */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 15, 0, 16, 0, 0, 0, 0, 0 },
/* b */ { 2, 0, 0, 4, 5, 7, 0, 0, 0, 0, 0, 8, 9, 10, 11, 12, 0, 13, 0, 0, 0, 0, 22, 0, 0, 0 }, /* b */ { 2, 0, 0, 4, 5, 7, 0, 0, 0, 0, 0, 8, 9, 10, 11, 12, 0, 13, 0, 0, 0, 0, 22, 0, 0, 0 },
/* c */ { 3, 10, 12, 14, 16, 18, 21, 0, 0, 0, 0, 29, 33, 36, 42, 51, 53, 54, 55, 0, 57, 0, 60, 0, 0, 0 }, /* c */ { 3, 11, 14, 16, 18, 20, 23, 0, 0, 0, 0, 31, 35, 38, 44, 53, 55, 56, 57, 0, 59, 0, 62, 0, 0, 0 },
/* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 6, 15, 0, 16, 0, 0, 17, 0, 0, 19, 20, 0, 0, 0, 0, 0, 0, 0 }, /* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 6, 15, 0, 16, 0, 0, 17, 0, 0, 19, 20, 0, 0, 0, 0, 0, 0, 0 },
/* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0 }, /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0 },
/* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0 }, /* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0 },
Expand All @@ -52,7 +52,7 @@ static const unsigned char cmdidxs2[26][26] =
/* i */ { 1, 0, 0, 0, 0, 3, 0, 0, 0, 4, 0, 5, 6, 0, 0, 0, 0, 0, 13, 0, 15, 0, 0, 0, 0, 0 }, /* i */ { 1, 0, 0, 0, 0, 3, 0, 0, 0, 4, 0, 5, 6, 0, 0, 0, 0, 0, 13, 0, 15, 0, 0, 0, 0, 0 },
/* j */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* j */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
/* k */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* k */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* l */ { 3, 9, 11, 15, 16, 20, 23, 28, 0, 0, 0, 30, 33, 36, 40, 46, 0, 48, 57, 49, 50, 54, 56, 0, 0, 0 }, /* l */ { 3, 10, 13, 17, 18, 22, 25, 30, 0, 0, 0, 32, 35, 38, 42, 48, 0, 50, 59, 51, 52, 56, 58, 0, 0, 0 },
/* m */ { 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 }, /* m */ { 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 },
/* n */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 10, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0 }, /* n */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 10, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0 },
/* o */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0 }, /* o */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0 },
Expand All @@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } /* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; };


static const int command_count = 550; static const int command_count = 554;
12 changes: 12 additions & 0 deletions src/ex_cmds.h
Expand Up @@ -252,6 +252,9 @@ EX(CMD_cabbrev, "cabbrev", ex_abbreviate,
EX(CMD_cabclear, "cabclear", ex_abclear, EX(CMD_cabclear, "cabclear", ex_abclear,
EXTRA|TRLBAR|CMDWIN, EXTRA|TRLBAR|CMDWIN,
ADDR_NONE), ADDR_NONE),
EX(CMD_cabove, "cabove", ex_cbelow,
RANGE|TRLBAR,
ADDR_OTHER),
EX(CMD_caddbuffer, "caddbuffer", ex_cbuffer, EX(CMD_caddbuffer, "caddbuffer", ex_cbuffer,
RANGE|WORD1|TRLBAR, RANGE|WORD1|TRLBAR,
ADDR_OTHER), ADDR_OTHER),
Expand All @@ -270,6 +273,9 @@ EX(CMD_catch, "catch", ex_catch,
EX(CMD_cbuffer, "cbuffer", ex_cbuffer, EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
BANG|RANGE|WORD1|TRLBAR, BANG|RANGE|WORD1|TRLBAR,
ADDR_OTHER), ADDR_OTHER),
EX(CMD_cbelow, "cbelow", ex_cbelow,
RANGE|TRLBAR,
ADDR_OTHER),
EX(CMD_cbottom, "cbottom", ex_cbottom, EX(CMD_cbottom, "cbottom", ex_cbottom,
TRLBAR, TRLBAR,
ADDR_NONE), ADDR_NONE),
Expand Down Expand Up @@ -726,6 +732,9 @@ EX(CMD_lNfile, "lNfile", ex_cnext,
EX(CMD_last, "last", ex_last, EX(CMD_last, "last", ex_last,
EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR, EXTRA|BANG|EDITCMD|ARGOPT|TRLBAR,
ADDR_NONE), ADDR_NONE),
EX(CMD_labove, "labove", ex_cbelow,
RANGE|TRLBAR,
ADDR_OTHER),
EX(CMD_language, "language", ex_language, EX(CMD_language, "language", ex_language,
EXTRA|TRLBAR|CMDWIN, EXTRA|TRLBAR|CMDWIN,
ADDR_NONE), ADDR_NONE),
Expand All @@ -744,6 +753,9 @@ EX(CMD_later, "later", ex_later,
EX(CMD_lbuffer, "lbuffer", ex_cbuffer, EX(CMD_lbuffer, "lbuffer", ex_cbuffer,
BANG|RANGE|WORD1|TRLBAR, BANG|RANGE|WORD1|TRLBAR,
ADDR_OTHER), ADDR_OTHER),
EX(CMD_lbelow, "lbelow", ex_cbelow,
RANGE|TRLBAR,
ADDR_OTHER),
EX(CMD_lbottom, "lbottom", ex_cbottom, EX(CMD_lbottom, "lbottom", ex_cbottom,
TRLBAR, TRLBAR,
ADDR_NONE), ADDR_NONE),
Expand Down
1 change: 1 addition & 0 deletions src/ex_docmd.c
Expand Up @@ -56,6 +56,7 @@ static int getargopt(exarg_T *eap);
# define ex_cbuffer ex_ni # define ex_cbuffer ex_ni
# define ex_cc ex_ni # define ex_cc ex_ni
# define ex_cnext ex_ni # define ex_cnext ex_ni
# define ex_cbelow ex_ni
# define ex_cfile ex_ni # define ex_cfile ex_ni
# define qf_list ex_ni # define qf_list ex_ni
# define qf_age ex_ni # define qf_age ex_ni
Expand Down
1 change: 1 addition & 0 deletions src/proto/quickfix.pro
Expand Up @@ -23,6 +23,7 @@ int qf_get_cur_idx(exarg_T *eap);
int qf_get_cur_valid_idx(exarg_T *eap); int qf_get_cur_valid_idx(exarg_T *eap);
void ex_cc(exarg_T *eap); void ex_cc(exarg_T *eap);
void ex_cnext(exarg_T *eap); void ex_cnext(exarg_T *eap);
void ex_cbelow(exarg_T *eap);
void ex_cfile(exarg_T *eap); void ex_cfile(exarg_T *eap);
void ex_vimgrep(exarg_T *eap); void ex_vimgrep(exarg_T *eap);
int get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list); int get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list);
Expand Down

0 comments on commit 3ff3311

Please sign in to comment.