Skip to content

Commit 01c1da1

Browse files
committed
Add vim_input wrapper and use it to pass keys on tests
This is done to get out of any "press enter to continue" screens, because Nvim no longer handles deferred events(such as calls to vim_command or vim_eval) when in that state.
1 parent 9f18faa commit 01c1da1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

neovim/api/nvim.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ def feedkeys(self, keys, options=''):
149149
"""
150150
return self._session.request('vim_feedkeys', keys, options)
151151

152+
def input(self, bytes):
153+
"""Push `bytes` to Nvim low level input buffer.
154+
155+
Unlike `feedkeys()`, this uses the lowest level input buffer and the
156+
call is not deferred. It returns the number of bytes actually
157+
written(which can be less than what was requested if the buffer is
158+
full).
159+
"""
160+
return self._session.request('vim_input', bytes)
161+
152162
def replace_termcodes(self, string, from_part=False, do_lt=True,
153163
special=True):
154164
r"""Replace any terminal code strings by byte sequences.

test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
endfunction
6262
'''
6363

64-
vim.feedkeys(cleanup_func)
64+
vim.input(cleanup_func)
6565

6666
def cleanup():
6767
# cleanup nvim

test/test_vim.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def test_command():
99
fname = tempfile.mkstemp()[1]
1010
vim.command('new')
1111
vim.command('edit %s' % fname)
12+
# skip the "press return" state, which does not handle deferred calls
13+
vim.input('\r')
1214
vim.command('normal itesting\npython\napi')
1315
vim.command('w')
1416
ok(os.path.isfile(fname))

0 commit comments

Comments
 (0)