Skip to content

Commit d01289e

Browse files
committed
fix #291
1 parent 2a73331 commit d01289e

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Diff for: changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.7.0
44
* `CHG` diagnostic: `unused-function` ignores function with `<close>`
55
* `FIX` semantic: tokens may not be updated correctly
6+
* `FIX` [#291](https://github.com/sumneko/lua-language-server/issues/291)
67

78
## 1.6.0
89
`2020-12-14`

Diff for: script/files.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ end
367367
---@param uri string
368368
---@return boolean
369369
function m.isLua(uri)
370-
local ext = uri:match '%.([^%.%/%\\]-)$'
370+
local ext = uri:match '%.([^%.%/%\\]+)$'
371371
if not ext then
372372
return false
373373
end

Diff for: script/glob/gitignore.lua

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
local parser = m.P {
2020
'Main',
2121
['Sp'] = m.S(' \t')^0,
22-
['Slash'] = m.S('/\\')^1,
22+
['Slash'] = m.S('/')^1,
2323
['Main'] = m.Ct(m.V'Sp' * m.P'{' * m.V'Pattern' * (',' * expect(m.V'Pattern', 'Miss exp after ","'))^0 * m.P'}')
2424
+ m.Ct(m.V'Pattern')
2525
+ m.T'Main Failed'
@@ -35,12 +35,15 @@ local parser = m.P {
3535
+ object('?', m.P'?')
3636
+ object('[]', m.V'Range')
3737
,
38-
['Char'] = object('char', (1 - m.S',{}[]*?/\\')^1),
38+
['SimpleChar'] = m.P(1) - m.S',{}[]*?/',
39+
['EscChar'] = m.P'\\' / '' * m.P(1),
40+
['Char'] = object('char', m.Cs((m.V'EscChar' + m.V'SimpleChar')^1)),
3941
['FSymbol'] = object('**', m.P'**'),
4042
['Range'] = m.P'[' * m.Ct(m.V'RangeUnit'^0) * m.P']'^-1,
4143
['RangeUnit'] = m.Ct(- m.P']' * m.C(m.P(1)) * (m.P'-' * - m.P']' * m.C(m.P(1)))^-1),
4244
}
4345

46+
---@class gitignore
4447
local mt = {}
4548
mt.__index = mt
4649
mt.__name = 'gitignore'
@@ -170,7 +173,9 @@ function mt:scan(callback)
170173
if type(result) == 'table' then
171174
for _, path in ipairs(result) do
172175
local filename = path:match '([^/\\]+)[/\\]*$'
173-
if filename then
176+
if filename
177+
and filename ~= '.'
178+
and filename ~= '..' then
174179
list[#list+1] = current .. '/' .. filename
175180
end
176181
end
@@ -185,6 +190,7 @@ function mt:__call(path)
185190
if self.options.ignoreCase then
186191
path = path:lower()
187192
end
193+
path = path:gsub('^[/\\]+', '')
188194
return self:finishMatch(path)
189195
end
190196

Diff for: script/glob/glob.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
local parser = m.P {
2020
'Main',
2121
['Sp'] = m.S(' \t')^0,
22-
['Slash'] = m.S('/\\')^1,
22+
['Slash'] = m.P('/')^1,
2323
['Main'] = m.Ct(m.V'Sp' * m.P'{' * m.V'Pattern' * (',' * expect(m.V'Pattern', 'Miss exp after ","'))^0 * m.P'}')
2424
+ m.Ct(m.V'Pattern')
2525
+ m.T'Main Failed'
@@ -35,7 +35,9 @@ local parser = m.P {
3535
+ object('?', m.P'?')
3636
+ object('[]', m.V'Range')
3737
,
38-
['Char'] = object('char', (1 - m.S',{}[]*?/\\')^1),
38+
['SimpleChar'] = m.P(1) - m.S',{}[]*?/',
39+
['EscChar'] = m.P'\\' / '' * m.P(1),
40+
['Char'] = object('char', m.Cs((m.V'EscChar' + m.V'SimpleChar')^1)),
3941
['FSymbol'] = object('**', m.P'**'),
4042
['RangeWord'] = 1 - m.P']',
4143
['Range'] = m.P'[' * m.Ct(m.V'RangeUnit'^0) * m.P']'^-1,
@@ -83,6 +85,7 @@ function mt:__call(path)
8385
if self.options.ignoreCase then
8486
path = path:lower()
8587
end
88+
path = path:gsub('^[/\\]+', '')
8689
for _, refused in ipairs(self.refused) do
8790
if refused(path) then
8891
return false

0 commit comments

Comments
 (0)