+30
-11
lines changedFilter options
+30
-11
lines changed Original file line number Diff line number Diff line change
@@ -2353,7 +2353,7 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
2353
2353
|api-indexing|
2354
2354
{opts} Optional parameters.
2355
2355
• id : id of the extmark to edit.
2356
-
• end_line : ending line of the mark, 0-based
2356
+
• end_row : ending line of the mark, 0-based
2357
2357
inclusive.
2358
2358
• end_col : ending col of the mark, 0-based
2359
2359
exclusive.
Original file line number Diff line number Diff line change
@@ -339,7 +339,7 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
339
339
/// @param col Column where to place the mark, 0-based. |api-indexing|
340
340
/// @param opts Optional parameters.
341
341
/// - id : id of the extmark to edit.
342
-
/// - end_line : ending line of the mark, 0-based inclusive.
342
+
/// - end_row : ending line of the mark, 0-based inclusive.
343
343
/// - end_col : ending col of the mark, 0-based exclusive.
344
344
/// - hl_group : name of the highlight group used to highlight
345
345
/// this mark.
@@ -431,16 +431,26 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
431
431
}
432
432
433
433
int line2 = -1;
434
-
if (opts->end_line.type == kObjectTypeInteger) {
435
-
Integer val = opts->end_line.data.integer;
434
+
435
+
// For backward compatibility we support "end_line" as an alias for "end_row"
436
+
if (HAS_KEY(opts->end_line)) {
437
+
if (HAS_KEY(opts->end_row)) {
438
+
api_set_error(err, kErrorTypeValidation, "cannot use both end_row and end_line");
439
+
goto error;
440
+
}
441
+
opts->end_row = opts->end_line;
442
+
}
443
+
444
+
if (opts->end_row.type == kObjectTypeInteger) {
445
+
Integer val = opts->end_row.data.integer;
436
446
if (val < 0 || val > buf->b_ml.ml_line_count) {
437
-
api_set_error(err, kErrorTypeValidation, "end_line value outside range");
447
+
api_set_error(err, kErrorTypeValidation, "end_row value outside range");
438
448
goto error;
439
449
} else {
440
450
line2 = (int)val;
441
451
}
442
-
} else if (HAS_KEY(opts->end_line)) {
443
-
api_set_error(err, kErrorTypeValidation, "end_line is not an integer");
452
+
} else if (HAS_KEY(opts->end_row)) {
453
+
api_set_error(err, kErrorTypeValidation, "end_row is not an integer");
444
454
goto error;
445
455
}
446
456
@@ -571,10 +581,10 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
571
581
OPTION_TO_BOOL(right_gravity, right_gravity, true);
572
582
573
583
// Only error out if they try to set end_right_gravity without
574
-
// setting end_col or end_line
584
+
// setting end_col or end_row
575
585
if (line2 == -1 && col2 == -1 && HAS_KEY(opts->end_right_gravity)) {
576
586
api_set_error(err, kErrorTypeValidation,
577
-
"cannot set end_right_gravity without setting end_line or end_col");
587
+
"cannot set end_right_gravity without setting end_row or end_col");
578
588
goto error;
579
589
}
580
590
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ return {
5
5
set_extmark = {
6
6
"id";
7
7
"end_line";
8
+
"end_row";
8
9
"end_col";
9
10
"hl_group";
10
11
"virt_text";
Original file line number Diff line number Diff line change
@@ -104,10 +104,10 @@ describe('API/extmarks', function()
104
104
it("can end extranges past final newline using end_col = 0", function()
105
105
set_extmark(ns, marks[1], 0, 0, {
106
106
end_col = 0,
107
-
end_line = 1
107
+
end_row = 1
108
108
})
109
109
eq("end_col value outside range",
110
-
pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_line = 1 }))
110
+
pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_row = 1 }))
111
111
end)
112
112
113
113
it('adds, updates and deletes marks', function()
@@ -1424,6 +1424,14 @@ describe('API/extmarks', function()
1424
1424
eq({ {1, 0, 0}, {2, 0, 8} },
1425
1425
meths.buf_get_extmarks(0, ns, 0, -1, {}))
1426
1426
end)
1427
+
1428
+
it('can accept "end_row" or "end_line" #16548', function()
1429
+
set_extmark(ns, marks[1], 0, 0, {
1430
+
end_col = 0,
1431
+
end_line = 1
1432
+
})
1433
+
eq({ {1, 0, 0, { end_col = 0, end_row = 1 }} }, get_extmarks(ns, 0, -1, {details=true}))
1434
+
end)
1427
1435
end)
1428
1436
1429
1437
describe('Extmarks buffer api with many marks', function()
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4