mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 11:25:33 +00:00
Merge #1342 "signs bugfix"
This commit is contained in:
@@ -96,6 +96,19 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt,
|
|||||||
return cstr_as_string(ptr);
|
return cstr_as_string(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String vim_command_output(String str, Error *err)
|
||||||
|
{
|
||||||
|
do_cmdline_cmd((char_u *)"redir => v:command_output");
|
||||||
|
vim_command(str, err);
|
||||||
|
do_cmdline_cmd((char_u *)"redir END");
|
||||||
|
|
||||||
|
if (err->set) {
|
||||||
|
return (String) STRING_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT));
|
||||||
|
}
|
||||||
|
|
||||||
/// Evaluates the expression str using the vim internal expression
|
/// Evaluates the expression str using the vim internal expression
|
||||||
/// evaluator (see |expression|).
|
/// evaluator (see |expression|).
|
||||||
/// Dictionaries and lists are recursively expanded.
|
/// Dictionaries and lists are recursively expanded.
|
||||||
|
|||||||
@@ -424,7 +424,8 @@ static struct vimvar {
|
|||||||
{VV_NAME("oldfiles", VAR_LIST), 0},
|
{VV_NAME("oldfiles", VAR_LIST), 0},
|
||||||
{VV_NAME("windowid", VAR_NUMBER), VV_RO},
|
{VV_NAME("windowid", VAR_NUMBER), VV_RO},
|
||||||
{VV_NAME("progpath", VAR_STRING), VV_RO},
|
{VV_NAME("progpath", VAR_STRING), VV_RO},
|
||||||
{VV_NAME("job_data", VAR_LIST), 0}
|
{VV_NAME("job_data", VAR_LIST), 0},
|
||||||
|
{VV_NAME("command_output", VAR_STRING), 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* shorthand */
|
/* shorthand */
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ enum {
|
|||||||
VV_WINDOWID,
|
VV_WINDOWID,
|
||||||
VV_PROGPATH,
|
VV_PROGPATH,
|
||||||
VV_JOB_DATA,
|
VV_JOB_DATA,
|
||||||
|
VV_COMMAND_OUTPUT,
|
||||||
VV_LEN, /* number of v: vars */
|
VV_LEN, /* number of v: vars */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5908,12 +5908,13 @@ void ex_sign(exarg_T *eap)
|
|||||||
arg = skipwhite(arg);
|
arg = skipwhite(arg);
|
||||||
if (idx == SIGNCMD_UNPLACE && *arg == NUL)
|
if (idx == SIGNCMD_UNPLACE && *arg == NUL)
|
||||||
{
|
{
|
||||||
/* ":sign unplace {id}": remove placed sign by number */
|
// ":sign unplace {id}": remove placed sign by number
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
if ((lnum = buf_delsign(buf, id)) != 0)
|
if ((lnum = buf_delsign(buf, id)) != 0) {
|
||||||
update_debug_sign(buf, lnum);
|
update_debug_sign(buf, lnum);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5923,7 +5924,7 @@ void ex_sign(exarg_T *eap)
|
|||||||
* Leave "arg" pointing to {fname}.
|
* Leave "arg" pointing to {fname}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
buf_T *buf = NULL;
|
buf_T *buf = NULL;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (STRNCMP(arg, "line=", 5) == 0)
|
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
|
||||||
|
|||||||
25
test/functional/ex_cmds/sign_spec.lua
Normal file
25
test/functional/ex_cmds/sign_spec.lua
Normal 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)
|
||||||
Reference in New Issue
Block a user