compat: "v:count" distinct from "count" (#7407)

This commit is contained in:
Marco Hinz 2017-11-09 02:20:12 +01:00 committed by Justin M. Keyes
parent 55d8967147
commit 9837a9c401
4 changed files with 10 additions and 2 deletions

View File

@ -1474,7 +1474,6 @@ v:count The count given for the last Normal mode command. Can be used
When there are two counts, as in "3d2w", they are multiplied, When there are two counts, as in "3d2w", they are multiplied,
just like what happens in the command, "d6w" for the example. just like what happens in the command, "d6w" for the example.
Also used for evaluating the 'formatexpr' option. Also used for evaluating the 'formatexpr' option.
"count" also works, for backwards compatibility.
*v:count1* *count1-variable* *v:count1* *count1-variable*
v:count1 Just like "v:count", but defaults to one when no count is v:count1 Just like "v:count", but defaults to one when no count is

View File

@ -298,6 +298,8 @@ Highlight groups:
|hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other |hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other
groups groups
The variable name "count" is no fallback for |v:count| anymore.
============================================================================== ==============================================================================
5. Missing legacy features *nvim-features-missing* 5. Missing legacy features *nvim-features-missing*

View File

@ -334,7 +334,7 @@ static struct vimvar {
// VV_SEND_SERVER "servername" // VV_SEND_SERVER "servername"
// VV_REG "register" // VV_REG "register"
// VV_OP "operator" // VV_OP "operator"
VV(VV_COUNT, "count", VAR_NUMBER, VV_COMPAT+VV_RO), VV(VV_COUNT, "count", VAR_NUMBER, VV_RO),
VV(VV_COUNT1, "count1", VAR_NUMBER, VV_RO), VV(VV_COUNT1, "count1", VAR_NUMBER, VV_RO),
VV(VV_PREVCOUNT, "prevcount", VAR_NUMBER, VV_RO), VV(VV_PREVCOUNT, "prevcount", VAR_NUMBER, VV_RO),
VV(VV_ERRMSG, "errmsg", VAR_STRING, VV_COMPAT), VV(VV_ERRMSG, "errmsg", VAR_STRING, VV_COMPAT),

View File

@ -168,4 +168,11 @@ describe('Special values', function()
'Expected True but got v:null', 'Expected True but got v:null',
}, meths.get_vvar('errors')) }, meths.get_vvar('errors'))
end) end)
describe('compat', function()
it('v:count is distinct from count', function()
command('let count = []') -- v:count is readonly
eq(1, eval('count is# g:["count"]'))
end)
end)
end) end)