mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 19:55:04 -07:00
Address review r3
This commit is contained in:
parent
2fd8330628
commit
facd07bcf7
@ -445,9 +445,18 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
||||
opts->end_row = opts->end_line;
|
||||
}
|
||||
|
||||
#define OPTION_TO_BOOL(target, name, val) \
|
||||
target = api_object_to_bool(opts->name, #name, val, err); \
|
||||
if (ERROR_SET(err)) { \
|
||||
goto error; \
|
||||
}
|
||||
|
||||
bool strict = true;
|
||||
OPTION_TO_BOOL(strict, strict, true);
|
||||
|
||||
if (opts->end_row.type == kObjectTypeInteger) {
|
||||
Integer val = opts->end_row.data.integer;
|
||||
if (val < 0 || val > buf->b_ml.ml_line_count) {
|
||||
if (val < 0 || (val > buf->b_ml.ml_line_count && strict)) {
|
||||
api_set_error(err, kErrorTypeValidation, "end_row value outside range");
|
||||
goto error;
|
||||
} else {
|
||||
@ -516,12 +525,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
||||
goto error;
|
||||
}
|
||||
|
||||
#define OPTION_TO_BOOL(target, name, val) \
|
||||
target = api_object_to_bool(opts->name, #name, val, err); \
|
||||
if (ERROR_SET(err)) { \
|
||||
goto error; \
|
||||
}
|
||||
|
||||
OPTION_TO_BOOL(decor.virt_text_hide, virt_text_hide, false);
|
||||
OPTION_TO_BOOL(decor.hl_eol, hl_eol, false);
|
||||
|
||||
@ -600,9 +603,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
||||
bool ephemeral = false;
|
||||
OPTION_TO_BOOL(ephemeral, ephemeral, false);
|
||||
|
||||
bool strict = true;
|
||||
OPTION_TO_BOOL(strict, strict, true);
|
||||
|
||||
if (line < 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "line value outside range");
|
||||
goto error;
|
||||
|
@ -110,6 +110,22 @@ describe('API/extmarks', function()
|
||||
pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_row = 1 }))
|
||||
end)
|
||||
|
||||
it("can end extranges past final newline when strict mode is false", function()
|
||||
set_extmark(ns, marks[1], 0, 0, {
|
||||
end_col = 1,
|
||||
end_row = 1,
|
||||
strict = false
|
||||
})
|
||||
end)
|
||||
|
||||
it("can end extranges past final column when strict mode is false", function()
|
||||
set_extmark(ns, marks[1], 0, 0, {
|
||||
end_col = 1,
|
||||
end_row = 6,
|
||||
strict = false
|
||||
})
|
||||
end)
|
||||
|
||||
it('adds, updates and deletes marks', function()
|
||||
local rv = set_extmark(ns, marks[1], positions[1][1], positions[1][2])
|
||||
eq(marks[1], rv)
|
||||
|
Loading…
Reference in New Issue
Block a user