From 41edb05b035c53bc396bf11fb2815ab03f65a2fc Mon Sep 17 00:00:00 2001 From: Mingxiang Xue Date: Mon, 9 May 2022 16:33:46 +0800 Subject: [PATCH] Evaluate v:true/v:false to python bool type Signed-off-by: Mingxiang Xue --- pynvim/plugin/script_host.py | 2 +- test/test_host.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pynvim/plugin/script_host.py b/pynvim/plugin/script_host.py index 36893176..1efb9457 100644 --- a/pynvim/plugin/script_host.py +++ b/pynvim/plugin/script_host.py @@ -194,7 +194,7 @@ def writelines(self, seq): def num_to_str(obj): - if isinstance(obj, num_types): + if isinstance(obj, num_types) and not isinstance(obj, bool): return str(obj) else: return obj diff --git a/test/test_host.py b/test/test_host.py index b21a398b..92de91fe 100644 --- a/test/test_host.py +++ b/test/test_host.py @@ -28,3 +28,10 @@ def test_host_async_error(vim): assert event[1] == 'nvim_error_event' assert 'rplugin-host: Async request caused an error:\nboom\n' \ in h._on_error_event(None, 'boom') + +def test_legacy_vim_eval(vim): + h = ScriptHost(vim) + assert h.legacy_vim.eval('1') == '1' + assert h.legacy_vim.eval('v:null') == None + assert h.legacy_vim.eval('v:true') == True + assert h.legacy_vim.eval('v:false') == False