diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-10 23:22:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-10 23:22:30 +0800 |
commit | 74eb42c4f89b06a57e5c157b0b9b7a93b4d7139f (patch) | |
tree | a4e8b87c3e0d6afff899c63ee9868fea22fa9ba5 /server-beta | |
parent | 79ebe02d82c1f3b527bf2a926cdcd23b57177bd6 (diff) | |
download | lua-language-server-74eb42c4f89b06a57e5c157b0b9b7a93b4d7139f.zip |
修正文件路径匹配的bug
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/service/service.lua | 4 | ||||
-rw-r--r-- | server-beta/src/workspace/workspace.lua | 19 | ||||
-rw-r--r-- | server-beta/test.lua | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/server-beta/src/service/service.lua b/server-beta/src/service/service.lua index 388f96c4..7b0b8ad5 100644 --- a/server-beta/src/service/service.lua +++ b/server-beta/src/service/service.lua @@ -42,7 +42,7 @@ function m.reportMemory() local lines = {} lines[#lines+1] = ' --------------- Memory ---------------' - lines[#lines+1] = (' Total: %.3 MB'):format(totalMem / 1000.0) + lines[#lines+1] = (' Total: %.3f MB'):format(totalMem / 1000.0) for i = 0, #mems do lines[#lines+1] = (' # %02d : %.3f MB'):format(i, mems[i] / 1000.0) end @@ -92,7 +92,7 @@ function m.reportCache() end local lines = {} - lines[#lines+1] = ' --------------- Coroutine ---------------' + lines[#lines+1] = ' --------------- Cache ---------------' lines[#lines+1] = (' Total: %d'):format(total) lines[#lines+1] = (' Dead: %d'):format(dead) return table.concat(lines, '\n') diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua index b335c51a..d5e6310e 100644 --- a/server-beta/src/workspace/workspace.lua +++ b/server-beta/src/workspace/workspace.lua @@ -146,13 +146,20 @@ function m.findUrisByFilePath(path, whole) for uri in files.eachFile() do local pathLen = #path local uriLen = #uri - for i = uriLen, uriLen - pathLen + 1, -1 do - local see = uri:sub(i - pathLen + 1, i) - if files.eq(see, path) then - results[#results+1] = uri + if whole then + local seg = uri:sub(uriLen - pathLen, uriLen - pathLen) + if seg == '/' or seg == '\\' or seg == '' then + local see = uri:sub(uriLen - pathLen + 1, uriLen) + if files.eq(see, path) then + results[#results+1] = uri + end end - if not whole then - break + else + for i = uriLen, uriLen - pathLen + 1, -1 do + local see = uri:sub(i - pathLen + 1, i) + if files.eq(see, path) then + results[#results+1] = uri + end end end end diff --git a/server-beta/test.lua b/server-beta/test.lua index ad282687..3ebfca70 100644 --- a/server-beta/test.lua +++ b/server-beta/test.lua @@ -38,7 +38,7 @@ local function main() test 'definition' test 'diagnostics' - test 'references' + --test 'references' --test 'highlight' --test 'rename' --test 'type_inference' |