Skip to content

Commit cf6a55c

Browse files
committed
patch 8.1.1275: cannot navigate to errors before/after the cursor
Problem: Cannot navigate to errors before/after the cursor. Solution: Add the :cbefore and :cafter commands. (Yegappan Lakshmanan, closes #4340)
1 parent ce79353 commit cf6a55c

File tree

7 files changed

+297
-81
lines changed

7 files changed

+297
-81
lines changed

runtime/doc/index.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,11 @@ tag command action ~
11921192
|:caddbuffer| :cad[dbuffer] add errors from buffer
11931193
|:caddexpr| :cadde[xpr] add errors from expr
11941194
|:caddfile| :caddf[ile] add error message to current quickfix list
1195+
|:cafter| :caf[ter] go to error after current cursor
11951196
|:call| :cal[l] call a function
11961197
|:catch| :cat[ch] part of a :try command
1197-
|:cbelow| :cbe[low] got to error below current line
1198+
|:cbefore| :cbef[ore] go to error before current cursor
1199+
|:cbelow| :cbel[ow] go to error below current line
11981200
|:cbottom| :cbo[ttom] scroll to the bottom of the quickfix window
11991201
|:cbuffer| :cb[uffer] parse error messages and jump to first error
12001202
|:cc| :cc go to specific error
@@ -1356,10 +1358,12 @@ tag command action ~
13561358
|:laddexpr| :lad[dexpr] add locations from expr
13571359
|:laddbuffer| :laddb[uffer] add locations from buffer
13581360
|:laddfile| :laddf[ile] add locations to current location list
1361+
|:lafter| :laf[ter] go to location after current cursor
13591362
|:last| :la[st] go to the last file in the argument list
13601363
|:language| :lan[guage] set the language (locale)
13611364
|:later| :lat[er] go to newer change, redo
1362-
|:lbelow| :lbe[low] go to location below current line
1365+
|:lbefore| :lbef[ore] go to location before current cursor
1366+
|:lbelow| :lbel[ow] go to location below current line
13631367
|:lbottom| :lbo[ttom] scroll to the bottom of the location window
13641368
|:lbuffer| :lb[uffer] parse locations and jump to first location
13651369
|:lcd| :lc[d] change directory locally

runtime/doc/quickfix.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,36 @@ processing a quickfix or location list command, it will be aborted.
152152
exceeds the number of entries below the current line,
153153
then the last error in the file is selected.
154154

155-
*:lbe* *:lbelow*
156-
:[count]lbe[low] Same as ":cbelow", except the location list for the
155+
*:lbel* *:lbelow*
156+
:[count]lbel[ow] Same as ":cbelow", except the location list for the
157+
current window is used instead of the quickfix list.
158+
159+
*:cbe* *:cbefore*
160+
:[count]cbe[fore] Go to the [count] error before the current cursor
161+
position in the current buffer. If [count] is
162+
omitted, then 1 is used. If there are no errors, then
163+
an error message is displayed. Assumes that the
164+
entries in a quickfix list are sorted by their buffer,
165+
line and column numbers. If [count] exceeds the
166+
number of entries before the current position, then
167+
the first error in the file is selected.
168+
169+
*:lbef* *:lbefore*
170+
:[count]lbef[ore] Same as ":cbefore", except the location list for the
171+
current window is used instead of the quickfix list.
172+
173+
*:caf* *:cafter*
174+
:[count]caf[ter] Go to the [count] error after the current cursor
175+
position in the current buffer. If [count] is
176+
omitted, then 1 is used. If there are no errors, then
177+
an error message is displayed. Assumes that the
178+
entries in a quickfix list are sorted by their buffer,
179+
line and column numbers. If [count] exceeds the
180+
number of entries after the current position, then
181+
the last error in the file is selected.
182+
183+
*:laf* *:lafter*
184+
:[count]laf[ter] Same as ":cafter", except the location list for the
157185
current window is used instead of the quickfix list.
158186

159187
*:cnf* *:cnfile*

src/ex_cmdidxs.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ static const unsigned short cmdidxs1[26] =
88
/* a */ 0,
99
/* b */ 19,
1010
/* c */ 42,
11-
/* d */ 105,
12-
/* e */ 127,
13-
/* f */ 147,
14-
/* g */ 163,
15-
/* h */ 169,
16-
/* i */ 178,
17-
/* j */ 196,
18-
/* k */ 198,
19-
/* l */ 203,
20-
/* m */ 263,
21-
/* n */ 281,
22-
/* o */ 301,
23-
/* p */ 313,
24-
/* q */ 352,
25-
/* r */ 355,
26-
/* s */ 375,
27-
/* t */ 443,
28-
/* u */ 488,
29-
/* v */ 499,
30-
/* w */ 517,
31-
/* x */ 531,
32-
/* y */ 540,
33-
/* z */ 541
11+
/* d */ 107,
12+
/* e */ 129,
13+
/* f */ 149,
14+
/* g */ 165,
15+
/* h */ 171,
16+
/* i */ 180,
17+
/* j */ 198,
18+
/* k */ 200,
19+
/* l */ 205,
20+
/* m */ 267,
21+
/* n */ 285,
22+
/* o */ 305,
23+
/* p */ 317,
24+
/* q */ 356,
25+
/* r */ 359,
26+
/* s */ 379,
27+
/* t */ 447,
28+
/* u */ 492,
29+
/* v */ 503,
30+
/* w */ 521,
31+
/* x */ 535,
32+
/* y */ 544,
33+
/* z */ 545
3434
};
3535

3636
/*
@@ -43,7 +43,7 @@ static const unsigned char cmdidxs2[26][26] =
4343
{ /* 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 */
4444
/* 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 },
4545
/* 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 },
46-
/* 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 },
46+
/* c */ { 3, 12, 16, 18, 20, 22, 25, 0, 0, 0, 0, 33, 37, 40, 46, 55, 57, 58, 59, 0, 61, 0, 64, 0, 0, 0 },
4747
/* 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 },
4848
/* 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 },
4949
/* 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 },
@@ -52,7 +52,7 @@ static const unsigned char cmdidxs2[26][26] =
5252
/* 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 },
5353
/* 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 },
5454
/* 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 },
55-
/* 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 },
55+
/* l */ { 3, 11, 15, 19, 20, 24, 27, 32, 0, 0, 0, 34, 37, 40, 44, 50, 0, 52, 61, 53, 54, 58, 60, 0, 0, 0 },
5656
/* 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 },
5757
/* 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 },
5858
/* 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 },
@@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
6969
/* 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 }
7070
};
7171

72-
static const int command_count = 554;
72+
static const int command_count = 558;

src/ex_cmds.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ EX(CMD_caddexpr, "caddexpr", ex_cexpr,
266266
EX(CMD_caddfile, "caddfile", ex_cfile,
267267
TRLBAR|FILE1,
268268
ADDR_NONE),
269+
EX(CMD_cafter, "cafter", ex_cbelow,
270+
RANGE|COUNT|TRLBAR,
271+
ADDR_UNSIGNED),
269272
EX(CMD_call, "call", ex_call,
270273
RANGE|NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN,
271274
ADDR_LINES),
@@ -275,6 +278,9 @@ EX(CMD_catch, "catch", ex_catch,
275278
EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
276279
BANG|RANGE|WORD1|TRLBAR,
277280
ADDR_OTHER),
281+
EX(CMD_cbefore, "cbefore", ex_cbelow,
282+
RANGE|COUNT|TRLBAR,
283+
ADDR_UNSIGNED),
278284
EX(CMD_cbelow, "cbelow", ex_cbelow,
279285
RANGE|COUNT|TRLBAR,
280286
ADDR_UNSIGNED),
@@ -749,12 +755,18 @@ EX(CMD_laddbuffer, "laddbuffer", ex_cbuffer,
749755
EX(CMD_laddfile, "laddfile", ex_cfile,
750756
TRLBAR|FILE1,
751757
ADDR_NONE),
758+
EX(CMD_lafter, "lafter", ex_cbelow,
759+
RANGE|COUNT|TRLBAR,
760+
ADDR_UNSIGNED),
752761
EX(CMD_later, "later", ex_later,
753762
TRLBAR|EXTRA|NOSPC|CMDWIN,
754763
ADDR_NONE),
755764
EX(CMD_lbuffer, "lbuffer", ex_cbuffer,
756765
BANG|RANGE|WORD1|TRLBAR,
757766
ADDR_OTHER),
767+
EX(CMD_lbefore, "lbefore", ex_cbelow,
768+
RANGE|COUNT|TRLBAR,
769+
ADDR_UNSIGNED),
758770
EX(CMD_lbelow, "lbelow", ex_cbelow,
759771
RANGE|COUNT|TRLBAR,
760772
ADDR_UNSIGNED),

0 commit comments

Comments
 (0)