|
1 | | -local lclient = require 'lclient' |
| 1 | +local lclient = require 'lclient'() |
2 | 2 | local furi = require 'file-uri' |
3 | 3 | local ws = require 'workspace' |
4 | 4 | local files = require 'files' |
@@ -41,8 +41,14 @@ util.enableCloseFunction() |
41 | 41 |
|
42 | 42 | local lastClock = os.clock() |
43 | 43 | local results = {} |
| 44 | + |
| 45 | +local function errorhandler(err) |
| 46 | + print(err) |
| 47 | + print(debug.traceback()) |
| 48 | +end |
| 49 | + |
44 | 50 | ---@async |
45 | | -lclient():start(function (client) |
| 51 | +xpcall(lclient.start, errorhandler, lclient, function (client) |
46 | 52 | client:registerFakers() |
47 | 53 |
|
48 | 54 | client:initialize { |
@@ -76,15 +82,27 @@ lclient():start(function (client) |
76 | 82 | for i, uri in ipairs(uris) do |
77 | 83 | files.open(uri) |
78 | 84 | diag.doDiagnostic(uri, true) |
79 | | - if os.clock() - lastClock > 0.2 then |
| 85 | + -- Print regularly but always print the last entry to ensure that logs written to files don't look incomplete. |
| 86 | + if os.clock() - lastClock > 0.2 or i == #uris then |
80 | 87 | lastClock = os.clock() |
| 88 | + client:update() |
81 | 89 | local output = '\x0D' |
82 | 90 | .. ('>'):rep(math.ceil(i / max * 20)) |
83 | 91 | .. ('='):rep(20 - math.ceil(i / max * 20)) |
84 | 92 | .. ' ' |
85 | 93 | .. ('0'):rep(#tostring(max) - #tostring(i)) |
86 | 94 | .. tostring(i) .. '/' .. tostring(max) |
87 | 95 | io.write(output) |
| 96 | + local filesWithErrors = 0 |
| 97 | + local errors = 0 |
| 98 | + for _, diags in pairs(results) do |
| 99 | + filesWithErrors = filesWithErrors + 1 |
| 100 | + errors = errors + #diags |
| 101 | + end |
| 102 | + if errors > 0 then |
| 103 | + local errorDetails = ' [' .. lang.script('CLI_CHECK_PROGRESS', errors, filesWithErrors) .. ']' |
| 104 | + io.write(errorDetails) |
| 105 | + end |
88 | 106 | io.flush() |
89 | 107 | end |
90 | 108 | end |
|
0 commit comments