summaryrefslogtreecommitdiff
path: root/test/tclient/tests/folders-with-single-file.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-01-23 04:18:52 +0800
committersumneko <sumneko@hotmail.com>2022-01-23 04:18:52 +0800
commita13a30f193b54f32138306463dd8e13d208fb45c (patch)
tree80ccf3511287bbeb5a4db4e5ea79b2867b4dbba2 /test/tclient/tests/folders-with-single-file.lua
parent1c8095439f8d738390b3cc19fa3f82853dd89f95 (diff)
downloadlua-language-server-a13a30f193b54f32138306463dd8e13d208fb45c.zip
fix
Diffstat (limited to 'test/tclient/tests/folders-with-single-file.lua')
-rw-r--r--test/tclient/tests/folders-with-single-file.lua66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/tclient/tests/folders-with-single-file.lua b/test/tclient/tests/folders-with-single-file.lua
new file mode 100644
index 00000000..326dd623
--- /dev/null
+++ b/test/tclient/tests/folders-with-single-file.lua
@@ -0,0 +1,66 @@
+local lclient = require 'tclient.lclient'
+local fs = require 'bee.filesystem'
+local util = require 'utility'
+local furi = require 'file-uri'
+local ws = require 'workspace'
+local files = require 'files'
+local scope = require 'workspace.scope'
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+
+ client:initialize {
+ rootUri = 'abc',
+ }
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = furi.encode('abc/1.lua'),
+ languageId = 'lua',
+ version = 0,
+ text = [[
+local x
+print(x)
+]]
+ }
+ })
+
+ ws.awaitReady('abc')
+
+ local locations = client:awaitRequest('textDocument/definition', {
+ textDocument = { uri = furi.encode('abc/1.lua') },
+ position = { line = 1, character = 7 },
+ })
+
+ assert(util.equal(locations, {
+ {
+ uri = furi.encode('abc/1.lua'),
+ range = {
+ start = { line = 0, character = 6 },
+ ['end'] = { line = 0, character = 7 },
+ }
+ }
+ }))
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = 'test://single-file.lua',
+ languageId = 'lua',
+ version = 0,
+ text = [[
+local x
+print(x)
+]]
+ }
+ })
+
+ ws.awaitReady(nil)
+
+ local locations = client:awaitRequest('textDocument/definition', {
+ textDocument = { uri = 'test://single-file.lua' },
+ position = { line = 1, character = 0 },
+ })
+
+ assert(#locations > 0)
+end)