Skip to content

Commit

Permalink
Revert "Ensure cursor position is counted by UTF16 (#657)"
Browse files Browse the repository at this point in the history
This reverts commit a8ad731.
  • Loading branch information
chemzqm committed Apr 6, 2019
1 parent aecaefd commit a0f8507
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions autoload/coc/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,11 @@ function! coc#util#yarn_cmd()
return ''
endfunction

function! s:count_utf16_code_units(str) abort
let l:rs = split(a:str, '\zs')
let l:len = len(l:rs)
return l:len + len(filter(l:rs, 'char2nr(v:val)>=0x10000'))
endfunction

" get cursor position
function! coc#util#cursor()
let pos = s:count_utf16_code_units(getline('.')[:col('.')-1])

This comment has been minimized.

Copy link
@Avi-D-coder

Avi-D-coder Apr 6, 2019

Contributor

@chemzqm Am correct in thinking that conversion to UTF-16 offsets is in the typescript, hence not need here?

This comment has been minimized.

Copy link
@chemzqm

chemzqm Apr 6, 2019

Author Member

Not needed, coc convert column to character by use javascript.

return [line('.') - 1, pos - 1]
let pos = getcurpos()
let content = pos[2] == 1 ? '' : getline('.')[0: pos[2] - 2]
return [pos[1] - 1, strchars(content)]
endfunction

function! coc#util#close_win(id)
Expand Down

0 comments on commit a0f8507

Please sign in to comment.