[RFC] extmark: fix E315 in nvim_buf_set_extmark (#11449)

extmark: need to use buf instead of curbuf
This commit is contained in:
notomo 2019-11-26 00:50:30 +09:00 committed by Björn Linse
parent fd5710ae9a
commit 4a77df2e51
2 changed files with 9 additions and 1 deletions

View File

@ -1207,7 +1207,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer id,
api_set_error(err, kErrorTypeValidation, "line value outside range"); api_set_error(err, kErrorTypeValidation, "line value outside range");
return 0; return 0;
} else if (line < buf->b_ml.ml_line_count) { } else if (line < buf->b_ml.ml_line_count) {
len = STRLEN(ml_get_buf(curbuf, (linenr_T)line+1, false)); len = STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
} }
if (col == -1) { if (col == -1) {

View File

@ -5,6 +5,7 @@ local request = helpers.request
local eq = helpers.eq local eq = helpers.eq
local ok = helpers.ok local ok = helpers.ok
local curbufmeths = helpers.curbufmeths local curbufmeths = helpers.curbufmeths
local bufmeths = helpers.bufmeths
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local insert = helpers.insert local insert = helpers.insert
local feed = helpers.feed local feed = helpers.feed
@ -1274,6 +1275,13 @@ describe('API/extmarks', function()
local id = set_extmark(ns, 0, 0, 2) local id = set_extmark(ns, 0, 0, 2)
eq({{id, 0, 2}}, get_extmarks(ns,0, -1)) eq({{id, 0, 2}}, get_extmarks(ns,0, -1))
end) end)
it('can set a mark to other buffer', function()
local buf = request('nvim_create_buf', 0, 1)
request('nvim_buf_set_lines', buf, 0, -1, 1, {"", ""})
local id = bufmeths.set_extmark(buf, ns, 0, 1, 0, {})
eq({{id, 1, 0}}, bufmeths.get_extmarks(buf, ns, 0, -1, {}))
end)
end) end)
describe('Extmarks buffer api with many marks', function() describe('Extmarks buffer api with many marks', function()