Skip to content

Commit b930764

Browse files
authored
Fix get_visual_selection for visual line mode (#1198) (#1199)
1 parent f926f8b commit b930764

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

autoload/LSP.vim

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,21 @@ function! s:get_position() abort
7373
\ }
7474
endfunction
7575

76-
function! s:get_visual_selection() abort
77-
let [line_start, column_start] = getpos("'<")[1:2]
78-
let [line_end, column_end] = getpos("'>")[1:2]
79-
let lines = getline(line_start, line_end)
80-
if len(lines) == 0
81-
echohl Error | echom '[LC] No lines found in range.' | echohl None
82-
return ''
83-
endif
84-
let lines[-1] = lines[-1][: column_end - 2]
85-
let lines[0] = lines[0][column_start - 1:]
86-
87-
return {
88-
\ 'start': {
89-
\ 'line': line_start - 1,
90-
\ 'character': column_start - 1,
91-
\ },
92-
\ 'end': {
93-
\ 'line': line_end - 1,
94-
\ 'character': column_end - 1,
95-
\ }
96-
\ }
76+
function! s:get_visual_selection() abort
77+
let line_start = line("'<")
78+
let column_start = col("'<")
79+
let line_end = line("'>")
80+
let column_end = col("'>")
81+
82+
"no selection -> all values are 0 -> [LC] invalid value: integer `-1`, expected u64
83+
return {
84+
\ 'start': {
85+
\ 'line': line_start - 1,
86+
\ 'character': column_start - 1,
87+
\ },
88+
\ 'end': {
89+
\ 'line': line_end - 1,
90+
\ 'character': column_end - 1,
91+
\ }
92+
\ }
9793
endfunction

0 commit comments

Comments
 (0)