From 9f3e010b21c987098d9698af899903f2c3742d45 Mon Sep 17 00:00:00 2001 From: Samuel Quinteiro Perez <119834862+samuelqp@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:36:59 -0400 Subject: [PATCH] Revert "fix: vim.eval('v:true') should return python bool" #562 Problem: Commit d549371b6fb647304cff5f88a71e2bc42d2ed30a added a check which degrades performance, making UltiSnips un-usable. Solution: Revert that change. Document as a "known issue". Fixes #523 --- README.md | 3 +++ pynvim/plugin/script_host.py | 2 +- test/test_host.py | 11 ----------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 26c4d908..bd91c8fa 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,9 @@ Pynvim defines some extensions over the vim python API: See the [Python Plugin API](http://pynvim.readthedocs.io/en/latest/usage/python-plugin-api.html) documentation for usage of this new functionality. +### Known Issues +- Vim evaluates `'v:'` to ``, whereas neovim evaluates to ``. This is expected behaviour due to the way booleans are implemented in python as explained [here](https://github.com/neovim/pynvim/issues/523#issuecomment-1495502011). + Development ----------- diff --git a/pynvim/plugin/script_host.py b/pynvim/plugin/script_host.py index f647e5e3..f382215a 100644 --- a/pynvim/plugin/script_host.py +++ b/pynvim/plugin/script_host.py @@ -195,7 +195,7 @@ def writelines(self, seq): def num_to_str(obj): - if isinstance(obj, num_types) and not isinstance(obj, bool): + if isinstance(obj, num_types): return str(obj) else: return obj diff --git a/test/test_host.py b/test/test_host.py index 18cff327..c404fdc3 100644 --- a/test/test_host.py +++ b/test/test_host.py @@ -56,14 +56,3 @@ 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) - try: - assert h.legacy_vim.eval('1') == '1' - assert h.legacy_vim.eval('v:null') is None - assert h.legacy_vim.eval('v:true') is True - assert h.legacy_vim.eval('v:false') is False - finally: - h.teardown()