Skip to content

Commit

Permalink
Fix getVisualSelection() when called from visual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-pouiller committed Nov 2, 2022
1 parent 735e929 commit a52e53a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugin/Highlight.vim
Expand Up @@ -1199,8 +1199,13 @@ function s:getVisualSelection()
" https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript
"
" Why is this not a built-in Vim script function?!
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
if mode()=="v"
let [line_start, column_start] = getpos("v")[1:2]
let [line_end, column_end] = getpos(".")[1:2]
else
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
end
let lines = getline(line_start, line_end)
if len(lines) == 0
return ''
Expand Down

0 comments on commit a52e53a

Please sign in to comment.