Skip to content

Commit d549371

Browse files
authored
fix: vim.eval('v:true') should return python bool #506
Signed-off-by: Mingxiang Xue <[email protected]>
1 parent 71102c0 commit d549371

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pynvim/plugin/script_host.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def writelines(self, seq):
194194

195195

196196
def num_to_str(obj):
197-
if isinstance(obj, num_types):
197+
if isinstance(obj, num_types) and not isinstance(obj, bool):
198198
return str(obj)
199199
else:
200200
return obj

test/test_host.py

+7
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ def test_host_async_error(vim):
2828
assert event[1] == 'nvim_error_event'
2929
assert 'rplugin-host: Async request caused an error:\nboom\n' \
3030
in h._on_error_event(None, 'boom')
31+
32+
def test_legacy_vim_eval(vim):
33+
h = ScriptHost(vim)
34+
assert h.legacy_vim.eval('1') == '1'
35+
assert h.legacy_vim.eval('v:null') == None
36+
assert h.legacy_vim.eval('v:true') == True
37+
assert h.legacy_vim.eval('v:false') == False

0 commit comments

Comments
 (0)