aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-05-14 12:30:47 -0700
committerGitHub <noreply@github.com>2021-05-14 12:30:47 -0700
commitba04b3d8381c1573fabbe2c78abe87b2b0dd0026 (patch)
treec509b8effd9c8a261127a0b0d8c73a4bc13c4b24 /runtime/lua/vim/lsp/util.lua
parent7c95697026e76f9ee817cbea5ab11232a2443c15 (diff)
parentc23640140dd6f8663cf2441ac2b09b6f02de7445 (diff)
downloadrneovim-ba04b3d8381c1573fabbe2c78abe87b2b0dd0026.tar.gz
rneovim-ba04b3d8381c1573fabbe2c78abe87b2b0dd0026.tar.bz2
rneovim-ba04b3d8381c1573fabbe2c78abe87b2b0dd0026.zip
Merge pull request #14555 from mickael-menu/fix/range-code-action
lsp: Fix range end offset off by one character
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ce8468aa8a..57919e907c 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1595,6 +1595,12 @@ function M.make_given_range_params(start_pos, end_pos)
if B[2] > 0 then
B = {B[1], M.character_offset(0, B[1], B[2])}
end
+ -- we need to offset the end character position otherwise we loose the last
+ -- character of the selection, as LSP end position is exclusive
+ -- see https://microsoft.github.io/language-server-protocol/specification#range
+ if vim.o.selection ~= 'exclusive' then
+ B[2] = B[2] + 1
+ end
return {
textDocument = M.make_text_document_params(),
range = {