diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-12 16:33:29 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-12 16:33:29 +0800 |
commit | ea2795520e68db8737bd6d0ab7a93d5e5a482346 (patch) | |
tree | 5f21f8392ad123497f52ab893e79cb3013879456 /script/workspace/scope.lua | |
parent | 896a1affdeed8304688611674df88140a5cc180e (diff) | |
download | lua-language-server-ea2795520e68db8737bd6d0ab7a93d5e5a482346.zip |
cleanup
Diffstat (limited to 'script/workspace/scope.lua')
-rw-r--r-- | script/workspace/scope.lua | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/script/workspace/scope.lua b/script/workspace/scope.lua index e6fcfeb7..da72a1eb 100644 --- a/script/workspace/scope.lua +++ b/script/workspace/scope.lua @@ -37,6 +37,12 @@ function mt:removeAllLinks() self._links = {} end +---@return fun(): uri +---@return table<uri, true> +function mt:eachLink() + return next, self._links +end + ---@param uri uri ---@return boolean function mt:isChildUri(uri) @@ -46,14 +52,14 @@ function mt:isChildUri(uri) if not self.uri then return false end - if self.uri == '' then - return true - end if self.uri == uri then return true end - if uri:sub(1, #self.uri) == self.uri - and uri:sub(#self.uri + 1, #self.uri + 1) == '/' then + if uri:sub(1, #self.uri) ~= self.uri then + return false + end + if uri:sub(#self.uri, #self.uri) == '/' + or uri:sub(#self.uri + 1, #self.uri + 1) == '/' then return true end return false @@ -69,10 +75,14 @@ function mt:isLinkedUri(uri) if uri == linkUri then return true end - if uri:sub(1, #linkUri) == linkUri - and uri:sub(#linkUri + 1, #linkUri + 1) == '/' then + if uri:sub(1, #linkUri) ~= linkUri then + goto CONTINUE + end + if uri:sub(#linkUri, #linkUri) == '/' + or uri:sub(#linkUri + 1, #linkUri + 1) == '/' then return true end + ::CONTINUE:: end return false end |