summaryrefslogtreecommitdiff
path: root/test/tclient
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-02-24 16:49:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-02-24 16:49:15 +0800
commitb313aa2c12cb560d0ffe01d3df5a70c66531fa8a (patch)
tree1268942fa1093b80fb59798a9ce3188c06c2386c /test/tclient
parentb37ebceffe695defd7e7976e653ce127618614c0 (diff)
downloadlua-language-server-b313aa2c12cb560d0ffe01d3df5a70c66531fa8a.zip
fix #965
Diffstat (limited to 'test/tclient')
-rw-r--r--test/tclient/init.lua1
-rw-r--r--test/tclient/tests/files-associations.lua48
2 files changed, 49 insertions, 0 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index 99b34867..7c8d70ef 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -3,3 +3,4 @@ require 'tclient.tests.library-ignore-limit'
require 'tclient.tests.multi-workspace'
require 'tclient.tests.folders-with-single-file'
require 'tclient.tests.load-library'
+require 'tclient.tests.files-associations'
diff --git a/test/tclient/tests/files-associations.lua b/test/tclient/tests/files-associations.lua
new file mode 100644
index 00000000..f8f862a9
--- /dev/null
+++ b/test/tclient/tests/files-associations.lua
@@ -0,0 +1,48 @@
+local lclient = require 'tclient.lclient'
+local ws = require 'workspace'
+local files = require 'files'
+local furi = require 'file-uri'
+local util = require 'utility'
+local fs = require 'bee.filesystem'
+
+local rootPath = LOGPATH .. '/files-associations'
+local rootUri = furi.encode(rootPath)
+
+fs.create_directories(fs.path(rootPath))
+
+local filePath = rootPath .. '/test.lua.txt'
+local fileUri = furi.encode(filePath)
+util.saveFile(filePath, '')
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+
+ client:register('workspace/configuration', function ()
+ return {
+ {},
+ {
+ ["*.lua.txt"] = "lua",
+ }
+ }
+ end)
+
+ client:initialize {
+ rootPath = rootPath,
+ rootUri = rootUri,
+ workspaceFolders = {
+ {
+ name = 'ws',
+ uri = rootUri,
+ },
+ }
+ }
+
+ ws.awaitReady(rootUri)
+
+ assert(files.isLua(furi.encode 'aaa.lua.txt') == true)
+ assert(files.isLua(furi.encode '/aaa.lua.txt') == true)
+ assert(files.isLua(furi.encode 'D:\\aaa.lua.txt') == true)
+ assert(files.isLua(fileUri) == true)
+ assert(files.exists(fileUri) == true)
+end)