summaryrefslogtreecommitdiff
path: root/test/tclient/tests
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/tests
parentb37ebceffe695defd7e7976e653ce127618614c0 (diff)
downloadlua-language-server-b313aa2c12cb560d0ffe01d3df5a70c66531fa8a.zip
fix #965
Diffstat (limited to 'test/tclient/tests')
-rw-r--r--test/tclient/tests/files-associations.lua48
1 files changed, 48 insertions, 0 deletions
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)