Skip to content

Commit

Permalink
feat: allow :wincmd to accept a count
Browse files Browse the repository at this point in the history
Lets the `:wincmd` command accept a count like its documentation suggests, previously it could only accept a range, which lead to some ambiguity on which attribute should be used when executing `wincmd` using `nvim_cmd`.

Closes #19662.

Also fixes a typo in a related Vim test which should be fixed in Vim by vim/vim#10932.
  • Loading branch information
famiu committed Aug 17, 2022
1 parent bccb5de commit 6f62206
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions runtime/doc/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ position is set to keep the same Visual area selected.
These commands can also be executed with ":wincmd":

:[count]winc[md] {arg}
:winc[md] [count] {arg}
Like executing CTRL-W [count] {arg}. Example: >
:wincmd j
< Moves to the window below the current one.
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/ex_cmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ module.cmds = {
},
{
command='wincmd',
flags=bit.bor(NEEDARG, WORD1, RANGE, CMDWIN, LOCK_OK),
flags=bit.bor(NEEDARG, WORD1, RANGE, COUNT, CMDWIN, LOCK_OK),
addr_type='ADDR_OTHER',
func='ex_wincmd',
},
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/testdir/test_diffmode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Common_vert_split()

" Test diffoff
diffoff!
1wincmd 2
1wincmd w
let &diff = 1
let &fdm = diff_fdm
let &fdc = diff_fdc
Expand Down
12 changes: 12 additions & 0 deletions test/functional/ex_cmds/wincmd_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local helpers = require("test.functional.helpers")(after_each)
local clear = helpers.clear
local eq = helpers.eq
local meths = helpers.meths
local command = helpers.command

it(':wincmd accepts a count', function()
clear()
command('vsplit')
command('wincmd 2 w')
eq(meths.get_current_win().id, 1000)
end)

0 comments on commit 6f62206

Please sign in to comment.