diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-04-22 11:51:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 11:51:22 +0800 |
commit | fbf1be3e9619c38e3c93650a7ede256241f69f6e (patch) | |
tree | f06df3af46ef2885e930c550ddd4e02dbfeba7d8 /script | |
parent | 630d10981b350eec964958453273b90372318791 (diff) | |
parent | 577b2eb8c50b6d19c93e3d2937ec45c5ae3ca022 (diff) | |
download | lua-language-server-fbf1be3e9619c38e3c93650a7ede256241f69f6e.zip |
Merge pull request #2622 from emmericp/check-output
Output more details while running --check
Diffstat (limited to 'script')
-rw-r--r-- | script/cli/check.lua | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/script/cli/check.lua b/script/cli/check.lua index 5ac9ea13..3902c4aa 100644 --- a/script/cli/check.lua +++ b/script/cli/check.lua @@ -1,4 +1,4 @@ -local lclient = require 'lclient' +local lclient = require 'lclient'() local furi = require 'file-uri' local ws = require 'workspace' local files = require 'files' @@ -41,8 +41,14 @@ util.enableCloseFunction() local lastClock = os.clock() local results = {} + +local function errorhandler(err) + print(err) + print(debug.traceback()) +end + ---@async -lclient():start(function (client) +xpcall(lclient.start, errorhandler, lclient, function (client) client:registerFakers() client:initialize { @@ -76,8 +82,10 @@ lclient():start(function (client) for i, uri in ipairs(uris) do files.open(uri) diag.doDiagnostic(uri, true) - if os.clock() - lastClock > 0.2 then + -- Print regularly but always print the last entry to ensure that logs written to files don't look incomplete. + if os.clock() - lastClock > 0.2 or i == #uris then lastClock = os.clock() + client:update() local output = '\x0D' .. ('>'):rep(math.ceil(i / max * 20)) .. ('='):rep(20 - math.ceil(i / max * 20)) @@ -85,6 +93,16 @@ lclient():start(function (client) .. ('0'):rep(#tostring(max) - #tostring(i)) .. tostring(i) .. '/' .. tostring(max) io.write(output) + local filesWithErrors = 0 + local errors = 0 + for _, diags in pairs(results) do + filesWithErrors = filesWithErrors + 1 + errors = errors + #diags + end + if errors > 0 then + local errorDetails = ' [' .. lang.script('CLI_CHECK_PROGRESS', errors, filesWithErrors) .. ']' + io.write(errorDetails) + end io.flush() end end |