fix 'sign unplace id'

Since the introduction of the FOR_ALL_BUFFERS macro, 'sign unplace id'
without a buffer was only removing the sign from the first buffer rather
than all buffers, as described in the documentation.

  :help sign-unplace

--

modeline discussion: https://github.com/akkartik/neovim/commit/7863c247db#commitcomment-8342590
This commit is contained in:
Kartik K. Agaram 2014-10-27 13:29:44 -07:00 committed by Justin M. Keyes
parent 94f59fc9be
commit 250298884b
2 changed files with 34 additions and 7 deletions

View File

@ -5908,12 +5908,13 @@ void ex_sign(exarg_T *eap)
arg = skipwhite(arg);
if (idx == SIGNCMD_UNPLACE && *arg == NUL)
{
/* ":sign unplace {id}": remove placed sign by number */
FOR_ALL_BUFFERS(buf) {
if ((lnum = buf_delsign(buf, id)) != 0)
update_debug_sign(buf, lnum);
return;
}
// ":sign unplace {id}": remove placed sign by number
FOR_ALL_BUFFERS(buf) {
if ((lnum = buf_delsign(buf, id)) != 0) {
update_debug_sign(buf, lnum);
}
}
return;
}
}
}
@ -5923,7 +5924,7 @@ void ex_sign(exarg_T *eap)
* Leave "arg" pointing to {fname}.
*/
buf_T *buf = NULL;
buf_T *buf = NULL;
for (;;)
{
if (STRNCMP(arg, "line=", 5) == 0)
@ -6343,3 +6344,4 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
}
}
// vim: tabstop=8

View File

@ -0,0 +1,25 @@
local helpers = require('test.functional.helpers')
local clear, nvim, buffer, curbuf, curwin, eq, ok =
helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
helpers.eq, helpers.ok
describe('sign', function()
describe('unplace {id}', function()
describe('without specifying buffer', function()
it('deletes the sign from all buffers', function()
-- place a sign with id 34 to first buffer
nvim('command', 'sign define Foo text=+ texthl=Delimiter linehl=Comment')
local buf1 = nvim('eval', 'bufnr("%")')
nvim('command', 'sign place 34 line=3 name=Foo buffer='..buf1)
-- create a second buffer and place the sign on it as well
nvim('command', 'new')
local buf2 = nvim('eval', 'bufnr("%")')
nvim('command', 'sign place 34 line=3 name=Foo buffer='..buf2)
-- now unplace without specifying a buffer
nvim('command', 'sign unplace 34')
eq("\n--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf1))
eq("\n--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf2))
end)
end)
end)
end)