Skip to content

Commit

Permalink
Revert "fix: vim.eval('v:true') should return python bool" #562
Browse files Browse the repository at this point in the history
Problem:
Commit d549371 added a check which
degrades performance, making UltiSnips un-usable.

Solution:
Revert that change. Document as a "known issue".

Fixes #523
  • Loading branch information
samuelqp committed Mar 27, 2024
1 parent f9d839f commit 9f3e010
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<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).

Development
-----------

Expand Down
2 changes: 1 addition & 1 deletion pynvim/plugin/script_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions test/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 9f3e010

Please sign in to comment.