Skip to content

Commit e23a00e

Browse files
authored
Merge pull request #518 from prabirshrestha/fix-516
Fix #516
2 parents 60a1d58 + a20a0c1 commit e23a00e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

autoload/lsp/utils/text_edit.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ endfunction
217217

218218
function! s:generate_move_end_cmd(line_pos, character_pos) abort
219219
let l:result = printf('%dG0', a:line_pos) " move the line and set to the cursor at the beginning
220-
if a:character_pos > 0
220+
if a:character_pos > 1
221221
let l:result .= printf('%dl', a:character_pos) " move right until the character
222-
else
222+
elseif a:character_pos == 0
223223
let l:result = printf('%dG$', a:line_pos - 1) " move most right
224224
endif
225225
return l:result

test/lsp/utils/text_edit.vimspec

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,30 @@ Describe lsp#utils#text_edit
527527
" Make sure v:completed_item is not changed
528528
Assert Equals(v:completed_item, l:old_completed_item)
529529
End
530+
531+
It replaces entire buffer correctly when end column is 1
532+
call s:set_text(['foo', 'b'])
533+
534+
call lsp#utils#text_edit#apply_text_edits(
535+
\ expand('%'),
536+
\ [{
537+
\ 'range': {
538+
\ 'start': {
539+
\ 'line': 0,
540+
\ 'character': 0
541+
\ },
542+
\ 'end': {
543+
\ 'line': 1,
544+
\ 'character': 1
545+
\ }
546+
\ },
547+
\ 'newText': "x\ny\nz\n"
548+
\ }])
549+
550+
let l:buffer_text = s:get_text()
551+
Assert Equals(l:buffer_text, ['x', 'y', 'z', 'b', ''])
552+
End
553+
530554
End
531555
End
532556

0 commit comments

Comments
 (0)