fix(api): fix nvim_buf_set_extmark

Fix the problem of calling clear_virttext on undefined variables.
This commit is contained in:
erw7 2021-10-06 23:30:48 +09:00
parent acd5e831b6
commit 23383451b0

View File

@ -1561,17 +1561,18 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
Dict(set_extmark) *opts, Error *err) Dict(set_extmark) *opts, Error *err)
FUNC_API_SINCE(7) FUNC_API_SINCE(7)
{ {
Decoration decor = DECORATION_INIT;
buf_T *buf = find_buffer_by_handle(buffer, err); buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) { if (!buf) {
return 0; goto error;
} }
if (!ns_initialized((uint64_t)ns_id)) { if (!ns_initialized((uint64_t)ns_id)) {
api_set_error(err, kErrorTypeValidation, "Invalid ns_id"); api_set_error(err, kErrorTypeValidation, "Invalid ns_id");
return 0; goto error;
} }
uint64_t id = 0; uint64_t id = 0;
if (opts->id.type == kObjectTypeInteger && opts->id.data.integer > 0) { if (opts->id.type == kObjectTypeInteger && opts->id.data.integer > 0) {
id = (uint64_t)opts->id.data.integer; id = (uint64_t)opts->id.data.integer;
@ -1608,8 +1609,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error; goto error;
} }
Decoration decor = DECORATION_INIT;
if (HAS_KEY(opts->hl_group)) { if (HAS_KEY(opts->hl_group)) {
decor.hl_id = object_to_hl_id(opts->hl_group, "hl_group", err); decor.hl_id = object_to_hl_id(opts->hl_group, "hl_group", err);
if (ERROR_SET(err)) { if (ERROR_SET(err)) {
@ -1741,7 +1740,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
if (line < 0 || line > buf->b_ml.ml_line_count) { if (line < 0 || line > buf->b_ml.ml_line_count) {
api_set_error(err, kErrorTypeValidation, "line value outside range"); api_set_error(err, kErrorTypeValidation, "line value outside range");
return 0; goto error;
} else if (line < buf->b_ml.ml_line_count) { } else if (line < buf->b_ml.ml_line_count) {
len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false)); len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
} }
@ -1750,7 +1749,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
col = (Integer)len; col = (Integer)len;
} else if (col < -1 || col > (Integer)len) { } else if (col < -1 || col > (Integer)len) {
api_set_error(err, kErrorTypeValidation, "col value outside range"); api_set_error(err, kErrorTypeValidation, "col value outside range");
return 0; goto error;
} }
if (col2 >= 0) { if (col2 >= 0) {