aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2020-06-04 12:16:42 +0900
committerGitHub <noreply@github.com>2020-06-04 12:16:42 +0900
commit96568d5b076ec52069766089eb40a9b71f4f1dd9 (patch)
tree6a69556eacbbadd54ff1cd4a17e2c647dcae4c9b /test
parent8a1276005a1099187710bdcc19284de51a0aa89a (diff)
parent67eb3bfbc38b8d46dfb458698f1dc5f952229d4a (diff)
downloadrneovim-96568d5b076ec52069766089eb40a9b71f4f1dd9.tar.gz
rneovim-96568d5b076ec52069766089eb40a9b71f4f1dd9.tar.bz2
rneovim-96568d5b076ec52069766089eb40a9b71f4f1dd9.zip
Merge pull request #12343 from ndreas/fix/lsp-multibyte-indexing
Fix LSP multibyte indexing
Diffstat (limited to 'test')
-rw-r--r--test/functional/plugin/lsp_spec.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index f1478c782d..ea0f52c85b 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -1317,4 +1317,65 @@ describe('LSP', function()
eq("Unknown", exec_lua("return vim.lsp.util._get_symbol_kind_name(1000)"))
end)
end)
+
+ describe('lsp.util.jump_to_location', function()
+ local target_bufnr
+
+ before_each(function()
+ target_bufnr = exec_lua [[
+ local bufnr = vim.uri_to_bufnr("file://fake/uri")
+ local lines = {"1st line of text", "å å ɧ 汉语 ↥ 🤦 🦄"}
+ vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
+ return bufnr
+ ]]
+ end)
+
+ local location = function(start_line, start_char, end_line, end_char)
+ return {
+ uri = "file://fake/uri",
+ range = {
+ start = { line = start_line, character = start_char },
+ ["end"] = { line = end_line, character = end_char },
+ },
+ }
+ end
+
+ local jump = function(msg)
+ eq(true, exec_lua('return vim.lsp.util.jump_to_location(...)', msg))
+ eq(target_bufnr, exec_lua[[return vim.fn.bufnr('%')]])
+ return {
+ line = exec_lua[[return vim.fn.line('.')]],
+ col = exec_lua[[return vim.fn.col('.')]],
+ }
+ end
+
+ it('jumps to a Location', function()
+ local pos = jump(location(0, 9, 0, 9))
+ eq(1, pos.line)
+ eq(10, pos.col)
+ end)
+
+ it('jumps to a LocationLink', function()
+ local pos = jump({
+ targetUri = "file://fake/uri",
+ targetSelectionRange = {
+ start = { line = 0, character = 4 },
+ ["end"] = { line = 0, character = 4 },
+ },
+ targetRange = {
+ start = { line = 1, character = 5 },
+ ["end"] = { line = 1, character = 5 },
+ },
+ })
+ eq(1, pos.line)
+ eq(5, pos.col)
+ end)
+
+ it('jumps to the correct multibyte column', function()
+ local pos = jump(location(1, 2, 1, 2))
+ eq(2, pos.line)
+ eq(4, pos.col)
+ eq('å', exec_lua[[return vim.fn.expand('<cword>')]])
+ end)
+ end)
end)