test(lsp): file URIs do not allow relative paths

This commit is contained in:
Alessandro Pezzoni 2021-07-08 00:36:27 +01:00
parent ce5f4228aa
commit 82a443e1f3
3 changed files with 18 additions and 18 deletions

View File

@ -11,7 +11,7 @@ describe('vim.lsp.codelens', function()
after_each(helpers.clear) after_each(helpers.clear)
it('on_codelens_stores_and_displays_lenses', function() it('on_codelens_stores_and_displays_lenses', function()
local fake_uri = "file://fake/uri" local fake_uri = "file:///fake/uri"
local bufnr = exec_lua([[ local bufnr = exec_lua([[
fake_uri = ... fake_uri = ...
local bufnr = vim.uri_to_bufnr(fake_uri) local bufnr = vim.uri_to_bufnr(fake_uri)

View File

@ -49,7 +49,7 @@ describe('vim.lsp.diagnostic', function()
end end
]] ]]
fake_uri = "file://fake/uri" fake_uri = "file:///fake/uri"
exec_lua([[ exec_lua([[
fake_uri = ... fake_uri = ...

View File

@ -1147,14 +1147,14 @@ describe('LSP', function()
make_edit(0, 0, 0, 3, "First ↥ 🤦 🦄") make_edit(0, 0, 0, 3, "First ↥ 🤦 🦄")
}, },
textDocument = { textDocument = {
uri = "file://fake/uri"; uri = "file:///fake/uri";
version = editVersion version = editVersion
} }
} }
end end
before_each(function() before_each(function()
target_bufnr = exec_lua [[ target_bufnr = exec_lua [[
local bufnr = vim.uri_to_bufnr("file://fake/uri") local bufnr = vim.uri_to_bufnr("file:///fake/uri")
local lines = {"1st line of text", "2nd line of 语text"} local lines = {"1st line of text", "2nd line of 语text"}
vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
return bufnr return bufnr
@ -1234,7 +1234,7 @@ describe('LSP', function()
make_edit(row, 0, row, 1000, new_line) make_edit(row, 0, row, 1000, new_line)
}, },
textDocument = { textDocument = {
uri = "file://fake/uri"; uri = "file:///fake/uri";
version = editVersion version = editVersion
} }
} }
@ -1252,7 +1252,7 @@ describe('LSP', function()
before_each(function() before_each(function()
local ret = exec_lua [[ local ret = exec_lua [[
local bufnr = vim.uri_to_bufnr("file://fake/uri") local bufnr = vim.uri_to_bufnr("file:///fake/uri")
local lines = { local lines = {
"Original Line #1", "Original Line #1",
"Original Line #2" "Original Line #2"
@ -1532,19 +1532,19 @@ describe('LSP', function()
it('Convert Location[] to items', function() it('Convert Location[] to items', function()
local expected = { local expected = {
{ {
filename = 'fake/uri', filename = '/fake/uri',
lnum = 1, lnum = 1,
col = 3, col = 3,
text = 'testing' text = 'testing'
}, },
} }
local actual = exec_lua [[ local actual = exec_lua [[
local bufnr = vim.uri_to_bufnr("file://fake/uri") local bufnr = vim.uri_to_bufnr("file:///fake/uri")
local lines = {"testing", "123"} local lines = {"testing", "123"}
vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
local locations = { local locations = {
{ {
uri = 'file://fake/uri', uri = 'file:///fake/uri',
range = { range = {
start = { line = 0, character = 2 }, start = { line = 0, character = 2 },
['end'] = { line = 0, character = 3 }, ['end'] = { line = 0, character = 3 },
@ -1558,14 +1558,14 @@ describe('LSP', function()
it('Convert LocationLink[] to items', function() it('Convert LocationLink[] to items', function()
local expected = { local expected = {
{ {
filename = 'fake/uri', filename = '/fake/uri',
lnum = 1, lnum = 1,
col = 3, col = 3,
text = 'testing' text = 'testing'
}, },
} }
local actual = exec_lua [[ local actual = exec_lua [[
local bufnr = vim.uri_to_bufnr("file://fake/uri") local bufnr = vim.uri_to_bufnr("file:///fake/uri")
local lines = {"testing", "123"} local lines = {"testing", "123"}
vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
local locations = { local locations = {
@ -1779,14 +1779,14 @@ describe('LSP', function()
local expected = { local expected = {
{ {
col = 1, col = 1,
filename = 'test_a', filename = '/test_a',
kind = 'File', kind = 'File',
lnum = 2, lnum = 2,
text = '[File] TestA' text = '[File] TestA'
}, },
{ {
col = 1, col = 1,
filename = 'test_b', filename = '/test_b',
kind = 'Module', kind = 'Module',
lnum = 4, lnum = 4,
text = '[Module] TestB' text = '[Module] TestB'
@ -1809,7 +1809,7 @@ describe('LSP', function()
line = 2 line = 2
} }
}, },
uri = "file://test_a" uri = "file:///test_a"
}, },
contanerName = "TestAContainer" contanerName = "TestAContainer"
}, },
@ -1828,7 +1828,7 @@ describe('LSP', function()
line = 4 line = 4
} }
}, },
uri = "file://test_b" uri = "file:///test_b"
}, },
contanerName = "TestBContainer" contanerName = "TestBContainer"
} }
@ -1867,7 +1867,7 @@ describe('LSP', function()
before_each(function() before_each(function()
target_bufnr = exec_lua [[ target_bufnr = exec_lua [[
local bufnr = vim.uri_to_bufnr("file://fake/uri") local bufnr = vim.uri_to_bufnr("file:///fake/uri")
local lines = {"1st line of text", "å å ɧ 汉语 ↥ 🤦 🦄"} local lines = {"1st line of text", "å å ɧ 汉语 ↥ 🤦 🦄"}
vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines)
return bufnr return bufnr
@ -1876,7 +1876,7 @@ describe('LSP', function()
local location = function(start_line, start_char, end_line, end_char) local location = function(start_line, start_char, end_line, end_char)
return { return {
uri = "file://fake/uri", uri = "file:///fake/uri",
range = { range = {
start = { line = start_line, character = start_char }, start = { line = start_line, character = start_char },
["end"] = { line = end_line, character = end_char }, ["end"] = { line = end_line, character = end_char },
@ -1901,7 +1901,7 @@ describe('LSP', function()
it('jumps to a LocationLink', function() it('jumps to a LocationLink', function()
local pos = jump({ local pos = jump({
targetUri = "file://fake/uri", targetUri = "file:///fake/uri",
targetSelectionRange = { targetSelectionRange = {
start = { line = 0, character = 4 }, start = { line = 0, character = 4 },
["end"] = { line = 0, character = 4 }, ["end"] = { line = 0, character = 4 },