Skip to content

Commit

Permalink
Merge pull request #236 from bfredl/handle
Browse files Browse the repository at this point in the history
api: export Object.handle and make Buffer.number non-blocking
  • Loading branch information
bfredl committed Nov 10, 2016
2 parents 7692502 + 317abda commit 562eac9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion neovim/api/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def valid(self):
@property
def number(self):
"""Get the buffer number."""
return self.request('nvim_buf_get_number')
return self.handle


class Range(object):
Expand Down
3 changes: 3 additions & 0 deletions neovim/api/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Code shared between the API classes."""
import functools

from msgpack import unpackb

from ..compat import unicode_errors_default


Expand All @@ -21,6 +23,7 @@ def __init__(self, session, code_data):
"""
self._session = session
self.code_data = code_data
self.handle = unpackb(code_data[1])
self.api = RemoteApi(self, self._api_prefix)
self.vars = RemoteMap(self, self._api_prefix + 'get_var',
self._api_prefix + 'set_var')
Expand Down
14 changes: 14 additions & 0 deletions test/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,17 @@ def test_number():
eq(vim.current.window.number, curnum + 1)
vim.command('bot split')
eq(vim.current.window.number, curnum + 2)


@with_setup(setup=cleanup)
def test_handle():
hnd1 = vim.current.window.handle
vim.command('bot split')
hnd2 = vim.current.window.handle
ok(hnd2 != hnd1)
vim.command('bot split')
hnd3 = vim.current.window.handle
ok(hnd3 != hnd1)
ok(hnd3 != hnd2)
vim.command('wincmd w')
eq(vim.current.window.handle,hnd1)

0 comments on commit 562eac9

Please sign in to comment.