Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 8851e05
Author: Nate Bosch <[email protected]>
Date:   Wed Jun 23 18:20:09 2021 -0700

    Fix cursor position following multibyte characters

    Closes natebosch#427

    Use `charcol` over `col` where it exists.
    Gate the function definition behind the feature check to avoid repeating
    it for every call.
  • Loading branch information
AlxKrispy committed Mar 21, 2022
1 parent 4b0fc48 commit ff58da9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- Avoid a state where no document highlights reference calls are made following
a server restart.
- Avoid creating public functions for callbacks which should be temporary.
- Fix character positions when the cursor is on a line following multibyte
characters for recent versions of vim. Older versions and neovim continue to
have incorrect positions.

**Minor breaking changes**
- Remove `noselect` from the default `completeopts` used during autocompletion.
Expand Down
41 changes: 28 additions & 13 deletions autoload/lsc/params.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@ function! lsc#params#textDocument() abort
return {'textDocument': {'uri': lsc#uri#documentUri()}}
endfunction

function! lsc#params#documentPosition() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'position': {'line': line('.') - 1, 'character': col('.') - 1}
\ }
endfunction

function! lsc#params#documentRange() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'range': {
\ 'start': {'line': line('.') - 1, 'character': col('.') - 1},
\ 'end': {'line': line('.') - 1, 'character': col('.')}},
\ }
endfunction
if exists('*charcol')
function! lsc#params#documentPosition() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'position': {'line': line('.') - 1, 'character': charcol('.') - 1}
\ }
endfunction
function! lsc#params#documentRange() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'range': {
\ 'start': {'line': line('.') - 1, 'character': charcol('.') - 1},
\ 'end': {'line': line('.') - 1, 'character': charcol('.')}},
\ }
endfunction
else
" TODO - this is broken following multibyte characters.
function! lsc#params#documentPosition() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'position': {'line': line('.') - 1, 'character': col('.') - 1}
\ }
endfunction
function! lsc#params#documentRange() abort
return { 'textDocument': {'uri': lsc#uri#documentUri()},
\ 'range': {
\ 'start': {'line': line('.') - 1, 'character': col('.') - 1},
\ 'end': {'line': line('.') - 1, 'character': col('.')}},
\ }
endfunction
endif

0 comments on commit ff58da9

Please sign in to comment.