From 1954384744225740c47275a2e91e1e91ba2a8add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Linse?= Date: Sun, 28 Aug 2016 21:16:45 +0200 Subject: [PATCH] Buffer: allow bytes to append --- neovim/api/buffer.py | 2 +- test/test_buffer.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/neovim/api/buffer.py b/neovim/api/buffer.py index fbc37480..29de15b6 100644 --- a/neovim/api/buffer.py +++ b/neovim/api/buffer.py @@ -104,7 +104,7 @@ def set_line_slice(self, start, stop, start_incl, end_incl, lines): def append(self, lines, index=-1): """Append a string or list of lines to the buffer.""" - if isinstance(lines, basestring): + if isinstance(lines, (basestring, bytes)): lines = [lines] return self._session.request('buffer_insert', self, index, lines) diff --git a/test/test_buffer.py b/test/test_buffer.py index cb863ccc..a99a9ce7 100644 --- a/test/test_buffer.py +++ b/test/test_buffer.py @@ -140,6 +140,8 @@ def test_append(): eq(vim.current.buffer[:], ['b', '', 'a', 'c', 'd']) vim.current.buffer.append(['c', 'd'], 2) eq(vim.current.buffer[:], ['b', '', 'c', 'd', 'a', 'c', 'd']) + vim.current.buffer.append(b'bytes') + eq(vim.current.buffer[:], ['b', '', 'c', 'd', 'a', 'c', 'd', 'bytes']) @with_setup(setup=cleanup)