Floobits / floobits-neovim

Floobits plugin for NeoVim
Apache License 2.0
167 stars 7 forks source link

Error handling non-ASCII characters #47

Open notgne2 opened 4 years ago

notgne2 commented 4 years ago

If any non-ASCII character (valid unicode) is present in a document being edited, text will cease to sync (cursors still work to an extent), and :FlooRefreshWorkspace will produce an error like this

error caught in async handler '/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits:command:FlooRefreshWorkspace ()'
Traceback (most recent call last):
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/__init__.py", line 89, in wrapped
    return func(*args, **kwargs)
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/__init__.py", line 154, in refresh_workspace
    G.AGENT.refresh_workspace()
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/common/utils.py", line 557, in wrap
    return _unwind_generator(f(*args, **kwargs))
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/common/utils.py", line 514, in _unwind_generator
    res = gen_expr.send(res)
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/common/handlers/floo_handler.py", line 541, in refresh_workspace
    changed_bufs, missing_bufs, new_files = self._scan_dir(self.bufs, G.IGNORE, read_only)
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/common/handlers/floo_handler.py", line 380, in _scan_dir
    view_text = view.get_text()
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/view.py", line 66, in get_text
    return vim_buf_to_text(self.vim_buf)
  File "/nix/store/6nq42slw1535ga03qga9qdp8pfv4zxdk-vimplugin-floobits-neovim-3.4.3/share/vim-plugins/floobits-neovim/rplugin/python/floobits/view.py", line 29, in vim_buf_to_text
    return text.decode('utf-8')
  File "/nix/store/8f6kdvqkdb2g7pr8x68lm9hjbw29gf7k-python-2.7.17/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 812: ordinal not in range(128)

This will work on the web editor and Sublime Text, but not on nvim, which is an issue as a lot of frontend projects will contain Unicode characters.