mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-23 02:23:07 +02:00
util: Make decode_bytes work correctly with neovim
Neovim with python3 behaves differently than vim with python3 (former returns str for variable queries, latter bytes).
This commit is contained in:
parent
c1d1dcd1f1
commit
ea6faa923f
1 changed files with 5 additions and 1 deletions
|
@ -14,7 +14,7 @@ from taskwiki import regexp
|
||||||
|
|
||||||
# Detect if command AnsiEsc is available
|
# Detect if command AnsiEsc is available
|
||||||
ANSI_ESC_AVAILABLE = vim.eval('exists(":AnsiEsc")') == '2'
|
ANSI_ESC_AVAILABLE = vim.eval('exists(":AnsiEsc")') == '2'
|
||||||
|
NEOVIM = (vim.eval('has("nvim")') == "1")
|
||||||
|
|
||||||
def tw_modstring_to_args(line):
|
def tw_modstring_to_args(line):
|
||||||
output = []
|
output = []
|
||||||
|
@ -387,9 +387,13 @@ def enforce_dependencies(cache):
|
||||||
def decode_bytes(var):
|
def decode_bytes(var):
|
||||||
"""
|
"""
|
||||||
Data structures obtained from vim under python3 will return bytestrings.
|
Data structures obtained from vim under python3 will return bytestrings.
|
||||||
|
Neovim under python3 will return str.
|
||||||
Make sure we can handle that.
|
Make sure we can handle that.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if NEOVIM:
|
||||||
|
return var
|
||||||
|
|
||||||
if isinstance(var, bytes):
|
if isinstance(var, bytes):
|
||||||
return var.decode()
|
return var.decode()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue