onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.35k stars 299 forks source link

Unicode issue: Autocompletion works buggy when cursor at middle of the line #402

Closed unclechu closed 6 years ago

unclechu commented 7 years ago

When cursor pointed on middle of the line and I press Enter to accept autocomplete suggestion it pastes text incorrectly.

Minimal Neovim config to reproduce:

filetype off
exec 'set rtp+='. ($HOME) .'/.config/nvim/bundle/Vundle.vim'
call vundle#begin($HOME . '/.config/nvim/bundle')
Plugin 'gmarik/Vundle.vim', {'pinned': 1} " provided by git-submodule
Plugin 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}
call vundle#end()
filetype plugin indent on
set hidden
let g:deoplete#enable_at_startup = 1

Short screencast that demonstrates the issue: https://youtu.be/LbiKwJZqaYs

:version from Neovim:

NVIM v0.2.0-dev
Build type: Debug
Compilation: /usr/bin/cc -Wconversion -DNVIM_MSGPACK_HAS_FLOAT32 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/build/config -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/src -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/.deps/usr/include -I/usr/include -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/build/src/nvim/auto -I/home/unclechu/.compile_n_build/neovim/neovim-v0.2.0-1338-g263849b/build/include
Compiled by unclechu@fedorafarm25

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/unclechu/neovim-v0.2.0-1338-g263849b/share/nvim"

The Oni built from 1aa7f4126414d33810aa9499b8dce4e190e02f86.

unclechu commented 7 years ago

I just realized that it doesn't act like this for everything, only when cursor is positioned after some unicode symbol. May be it counting columns by bytes and misses that not every symbol presented by same amount of bytes?

unclechu commented 7 years ago

I have another issues with unicode symbols, I don't need to open new issue for that because as I see it's unicode issue in general, am I right?

nvim TUI: neovim-oni-gui-unicode-issue-1-should-be neovim-oni-gui-unicode-issue-2-should-be Oni: neovim-oni-gui-unicode-issue-1-bug neovim-oni-gui-unicode-issue-2-bug

bryphe commented 7 years ago

Thanks for the detailed issue, @unclechu ! Having the screenshots is very helpful.

The autocompletion issue may be related to #376. There aren't any tests with that logic with Unicode strings, so it's possible that the logic being used there doesn't handle Unicode characters correctly.

The other issue seems related to the rendering strategy - it would be helpful to have a separate issue for that. The DOM renderer creates an element for strings, and it is sized to fit the string - if it doesn't measure the unicode characters correctly and the characters are wider, it can cause that wrapping behavior.

bryphe commented 7 years ago

@unclechu , couple of follow-up questions for you:

Thanks for your help!

unclechu commented 7 years ago

@extr0py

I'm assuming you're running on Fedora25, is that correct?

That is correct. Fedora 25 Workstation

Would you mind posting the init.vim with the xnoremap line that is problematic? I'm not able to repro these wrapping issues on Windows, but I'm wondering if it is specific to a font.

My config. But I didn't get which xnoremap matters? Are you about autocompletion? But it's default Oni's mapping (^N/^P/Enter).

Are you using the default font with Oni or have you overridden it with editor.fontFamily?

I'm using Fira Code for ligatures, here is source of my ~/.oni/config.js:

module.exports = {
        "oni.useDefaultConfig": true,
        "oni.loadInitVim": true,
        "editor.fontSize": "12px",
        "editor.fontFamily": "Fira Code",
        "editor.completions.enabled": true,
        "editor.fontLigatures": true,
        "oni.hideMenu": true,
}

Do you have a document I can reproduce the completion behavior on? Unfortunately the youtube video did not work for me.

You could use minimal config that I put in topic to reproduce it. Just use this example:

foo → + bar

Where + is your cursor position, type f and in autocompletion menu choose foo and then press Enter. I can reproduce it this way.

keforbes commented 7 years ago

@unclechu, now that #376 and #453 have been fixed, would you mind re-compiling from the latest commit and see if you can still reproduce this issue?

unclechu commented 7 years ago

@keforbes okay, will try soon.

unclechu commented 7 years ago

@keforbes I still can reproduce it: https://youtu.be/jcHkspllgvE Commit: b5ea293321e525e5d91035409d9634435bae3b2a

unclechu commented 7 years ago

@keforbes except text rendering, it looks like it's fixed.

This I cannot reproduce (fixed): unicode issue screenshot

bryphe commented 6 years ago

I believe this particular issue should be addressed with the autocompletion updates that came in 0.2.15. I'll close this for now, but let me know if you're still seeing the issue.