Skip to content

Commit 9f3e010

Browse files
authored
Revert "fix: vim.eval('v:true') should return python bool" #562
Problem: Commit d549371 added a check which degrades performance, making UltiSnips un-usable. Solution: Revert that change. Document as a "known issue". Fixes #523
1 parent f9d839f commit 9f3e010

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Pynvim defines some extensions over the vim python API:
4545

4646
See the [Python Plugin API](http://pynvim.readthedocs.io/en/latest/usage/python-plugin-api.html) documentation for usage of this new functionality.
4747

48+
### Known Issues
49+
- Vim evaluates `'v:<bool>'` to `<class 'bool'>`, whereas neovim evaluates to `<class 'str'>`. 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).
50+
4851
Development
4952
-----------
5053

pynvim/plugin/script_host.py

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

196196

197197
def num_to_str(obj):
198-
if isinstance(obj, num_types) and not isinstance(obj, bool):
198+
if isinstance(obj, num_types):
199199
return str(obj)
200200
else:
201201
return obj

test/test_host.py

-11
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,3 @@ def test_host_async_error(vim):
5656
assert event[1] == 'nvim_error_event'
5757
assert 'rplugin-host: Async request caused an error:\nboom\n' \
5858
in h._on_error_event(None, 'boom')
59-
60-
61-
def test_legacy_vim_eval(vim):
62-
h = ScriptHost(vim)
63-
try:
64-
assert h.legacy_vim.eval('1') == '1'
65-
assert h.legacy_vim.eval('v:null') is None
66-
assert h.legacy_vim.eval('v:true') is True
67-
assert h.legacy_vim.eval('v:false') is False
68-
finally:
69-
h.teardown()

0 commit comments

Comments
 (0)