Skip to content

Commit 562eac9

Browse files
authored
Merge pull request #236 from bfredl/handle
api: export Object.handle and make Buffer.number non-blocking
2 parents 7692502 + 317abda commit 562eac9

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

neovim/api/buffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def valid(self):
128128
@property
129129
def number(self):
130130
"""Get the buffer number."""
131-
return self.request('nvim_buf_get_number')
131+
return self.handle
132132

133133

134134
class Range(object):

neovim/api/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Code shared between the API classes."""
22
import functools
33

4+
from msgpack import unpackb
5+
46
from ..compat import unicode_errors_default
57

68

@@ -21,6 +23,7 @@ def __init__(self, session, code_data):
2123
"""
2224
self._session = session
2325
self.code_data = code_data
26+
self.handle = unpackb(code_data[1])
2427
self.api = RemoteApi(self, self._api_prefix)
2528
self.vars = RemoteMap(self, self._api_prefix + 'get_var',
2629
self._api_prefix + 'set_var')

test/test_window.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@ def test_number():
103103
eq(vim.current.window.number, curnum + 1)
104104
vim.command('bot split')
105105
eq(vim.current.window.number, curnum + 2)
106+
107+
108+
@with_setup(setup=cleanup)
109+
def test_handle():
110+
hnd1 = vim.current.window.handle
111+
vim.command('bot split')
112+
hnd2 = vim.current.window.handle
113+
ok(hnd2 != hnd1)
114+
vim.command('bot split')
115+
hnd3 = vim.current.window.handle
116+
ok(hnd3 != hnd1)
117+
ok(hnd3 != hnd2)
118+
vim.command('wincmd w')
119+
eq(vim.current.window.handle,hnd1)

0 commit comments

Comments
 (0)