diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-09 20:20:26 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-09 20:20:26 +0800 |
commit | ebc8c4d7c95fd1db872fae49a979ed1b7b5b5818 (patch) | |
tree | 4fb61f363ce1adb978bc4c9304d863f1f56fc15c | |
parent | 872334e6bec8b8b73a634f59969dd2a69d02f69d (diff) | |
download | lua-language-server-ebc8c4d7c95fd1db872fae49a979ed1b7b5b5818.zip |
display main errors first
-rw-r--r-- | .vscode/launch.json | 2 | ||||
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 28 |
3 files changed, 21 insertions, 10 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index 6567e714..86004596 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -29,7 +29,7 @@ "type": "lua", "request": "attach", "stopOnEntry": true, - "address": "127.0.0.1:11413", + "address": "127.0.0.1:11427", "outputCapture": [ ] }, diff --git a/changelog.md b/changelog.md index e0040339..37809faf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # changelog ## 1.15.0 +* `CHG` diagnostic: when there are too many errors, the main errors will be displayed first * `CHG` main thread no longer loop sleeps, see [#329](https://github.com/sumneko/lua-language-server/issues/329) [#386](https://github.com/sumneko/lua-language-server/issues/386) * `CHG` improve performance diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 792412c0..52ba3f87 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -90,25 +90,34 @@ local function buildDiagnostic(uri, diag) } end -local function merge(a, b) +local function mergeSyntaxAndDiags(a, b) if not a and not b then return nil end + local count = 0 local t = {} if a then for i = 1, #a do - if #t >= 100 then - break + local severity = a[i].severity + if severity == define.DiagnosticSeverity.Hint + or severity == define.DiagnosticSeverity.Information then + t[#t+1] = a[i] + elseif count < 10000 then + count = count + 1 + t[#t+1] = a[i] end - t[#t+1] = a[i] end end if b then for i = 1, #b do - if #t >= 100 then - break + local severity = b[i].severity + if severity == define.DiagnosticSeverity.Hint + or severity == define.DiagnosticSeverity.Information then + t[#t+1] = b[i] + elseif count < 10000 then + count = count + 1 + t[#t+1] = b[i] end - t[#t+1] = b[i] end end return t @@ -191,9 +200,10 @@ function m.doDiagnostic(uri) local syntax = m.syntaxErrors(uri, ast) local diags = {} - local function pushResult() - local full = merge(syntax, diags) + tracy.ZoneBeginN 'mergeSyntaxAndDiags' + local _ <close> = tracy.ZoneEnd + local full = mergeSyntaxAndDiags(syntax, diags) if not full then m.clear(uri) return |