diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 20:03:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 20:03:07 +0800 |
commit | eda1918a82894137c58e19a7fdb1301e3c2bbf30 (patch) | |
tree | 79fde9c5cc04b3bdb0cb9dc9cc64583e67ccd163 /script/vm | |
parent | 9c79a00b41e1eff3a04a3daea6762ece89bb60eb (diff) | |
download | lua-language-server-eda1918a82894137c58e19a7fdb1301e3c2bbf30.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getDocs.lua | 77 |
1 files changed, 34 insertions, 43 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index 7cac0935..0c6b1695 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -187,55 +187,49 @@ local function makeDiagRange(uri, doc, results) end local row = guide.rowColOf(doc.start) if doc.mode == 'disable-next-line' then - if lines[row+1] then - results[#results+1] = { - mode = 'disable', - names = names, - offset = lines[row+1].start, - source = doc, - } - results[#results+1] = { - mode = 'enable', - names = names, - offset = lines[row+1].finish, - source = doc, - } - end + results[#results+1] = { + mode = 'disable', + names = names, + row = row + 1, + source = doc, + } + results[#results+1] = { + mode = 'enable', + names = names, + row = row + 2, + source = doc, + } elseif doc.mode == 'disable-line' then results[#results+1] = { mode = 'disable', names = names, - offset = lines[row].start, + row = row, source = doc, } results[#results+1] = { mode = 'enable', names = names, - offset = lines[row].finish, + row = row + 1, source = doc, } elseif doc.mode == 'disable' then - if lines[row+1] then - results[#results+1] = { - mode = 'disable', - names = names, - offset = lines[row+1].start, - source = doc, - } - end + results[#results+1] = { + mode = 'disable', + names = names, + row = row + 1, + source = doc, + } elseif doc.mode == 'enable' then - if lines[row+1] then - results[#results+1] = { - mode = 'enable', - names = names, - offset = lines[row+1].start, - source = doc, - } - end + results[#results+1] = { + mode = 'enable', + names = names, + row = row + 1, + source = doc, + } end end -function vm.isDiagDisabledAt(uri, offset, name) +function vm.isDiagDisabledAt(uri, position, name) local status = files.getState(uri) if not status then return false @@ -252,29 +246,26 @@ function vm.isDiagDisabledAt(uri, offset, name) end end table.sort(cache.diagnosticRanges, function (a, b) - return a.offset < b.offset + return a.row < b.row end) end if #cache.diagnosticRanges == 0 then return false end - local stack = {} + local myRow = guide.rowColOf(position) + local count = 0 for _, range in ipairs(cache.diagnosticRanges) do - if range.offset <= offset then + if range.row <= myRow then if not range.names or range.names[name] then if range.mode == 'disable' then - stack[#stack+1] = range + count = count + 1 elseif range.mode == 'enable' then - stack[#stack] = nil + count = count - 1 end end else break end end - local current = stack[#stack] - if not current then - return false - end - return true + return count > 0 end |