Skip to content

Commit

Permalink
feat: allow :wincmd to accept a count (neovim#19815)
Browse files Browse the repository at this point in the history
Let :wincmd command accept a count like what its documentation suggests.
Previously it could only accept a range, which led to some ambiguity on
which attribute should be used when executing :wincmd using nvim_cmd.

Closes neovim#19662.

Also fix a typo in a related Vim test:

vim-patch:9.0.0223: typo in diffmode test

Problem:    Typo in diffmode test.
Solution:   Fix the typo. (closes vim/vim#10932)
vim/vim@5fd6ab8
  • Loading branch information
famiu authored and smjonas committed Dec 31, 2022
1 parent 2149c24 commit 159b18f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions runtime/doc/vim_diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ Lua interface (|lua.txt|):

Commands:
|:doautocmd| does not warn about "No matching autocommands".
|:wincmd| accepts a count.

Functions:
|input()| and |inputdialog()| support for each other’s features (return on
Expand Down
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
13 changes: 13 additions & 0 deletions test/functional/ex_cmds/wincmd_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local helpers = require("test.functional.helpers")(after_each)
local clear = helpers.clear
local eq = helpers.eq
local funcs = helpers.funcs
local command = helpers.command

it(':wincmd accepts a count', function()
clear()
command('vsplit')
eq(1, funcs.winnr())
command('wincmd 2 w')
eq(2, funcs.winnr())
end)

0 comments on commit 159b18f

Please sign in to comment.