Skip to content

Commit 44fb250

Browse files
committed
Fix vim.eval("[1, 2]") which was broken in the LegacyVim refactor
1 parent 7af000e commit 44fb250

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

neovim/plugin/script_host.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77

88
from .decorators import plugin, rpc_export
9-
from ..api import Nvim
9+
from ..api import Nvim, walk
1010

1111
__all__ = ('ScriptHost',)
1212

@@ -161,15 +161,23 @@ def writelines(self, seq):
161161
self.redirect_handler('\n'.join(seq))
162162

163163

164+
if IS_PYTHON3:
165+
num_types = (int, float)
166+
else:
167+
num_types = (int, long, float)
168+
169+
170+
def num_to_str(obj):
171+
if isinstance(obj, num_types):
172+
return str(obj)
173+
else:
174+
return obj
175+
176+
164177
class LegacyVim(Nvim):
165178
def eval(self, expr):
166179
obj = self.request("vim_eval", expr)
167-
if IS_PYTHON3:
168-
if isinstance(obj, (int, float)):
169-
return str(obj)
170-
elif isinstance(obj, (int, long, float)):
171-
return str(obj)
172-
return obj
180+
return walk(num_to_str, obj)
173181

174182

175183
# This was copied/adapted from nvim-python help

0 commit comments

Comments
 (0)