Skip to content

Commit f8d0c1f

Browse files
authored
Merge pull request #233 from jamessan/tab-win-nr
Add number attribute to Window and Tabpage objects
2 parents 4dbfbd1 + ce840cb commit f8d0c1f

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

neovim/api/tabpage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ def window(self):
2828
def valid(self):
2929
"""Return True if the tabpage still exists."""
3030
return self.request('tabpage_is_valid')
31+
32+
@property
33+
def number(self):
34+
"""Get the tabpage number."""
35+
return self.request('nvim_tabpage_get_number')

neovim/api/window.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ def tabpage(self):
6565
def valid(self):
6666
"""Return True if the window still exists."""
6767
return self.request('window_is_valid')
68+
69+
@property
70+
def number(self):
71+
"""Get the window number."""
72+
return self.request('nvim_win_get_number')

test/test_tabpage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ def test_valid():
2828
ok(tabpage.valid)
2929
vim.command('tabclose')
3030
ok(not tabpage.valid)
31+
32+
33+
@with_setup(setup=cleanup)
34+
def test_number():
35+
curnum = vim.current.tabpage.number
36+
vim.command('tabnew')
37+
eq(vim.current.tabpage.number, curnum + 1)
38+
vim.command('tabnew')
39+
eq(vim.current.tabpage.number, curnum + 2)

test/test_window.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,12 @@ def test_valid():
9494
ok(window.valid)
9595
vim.command('q')
9696
ok(not window.valid)
97+
98+
99+
@with_setup(setup=cleanup)
100+
def test_number():
101+
curnum = vim.current.window.number
102+
vim.command('bot split')
103+
eq(vim.current.window.number, curnum + 1)
104+
vim.command('bot split')
105+
eq(vim.current.window.number, curnum + 2)

0 commit comments

Comments
 (0)