Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fbf1be3

Browse files
authoredApr 22, 2024
Merge pull request #2622 from emmericp/check-output
Output more details while running --check
2 parents 630d109 + 577b2eb commit fbf1be3

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed
 

‎locale/en-us/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ CLI_CHECK_INITING =
646646
'Initializing ...'
647647
CLI_CHECK_SUCCESS =
648648
'Diagnosis completed, no problems found'
649+
CLI_CHECK_PROGRESS =
650+
'Found {} problems in {} files'
649651
CLI_CHECK_RESULTS =
650652
'Diagnosis complete, {} problems found, see {}'
651653
CLI_DOC_INITING =

‎locale/pt-br/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ CLI_CHECK_INITING =
646646
'Inicializando ...'
647647
CLI_CHECK_SUCCESS =
648648
'Diagnóstico completo, nenhum problema encontrado'
649+
CLI_CHECK_PROGRESS = -- TODO: need translate!
650+
'Found {} problems in {} files'
649651
CLI_CHECK_RESULTS =
650652
'Diagnóstico completo, {} problemas encontrados, veja {}'
651653
CLI_DOC_INITING = -- TODO: need translate!

‎locale/zh-cn/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ CLI_CHECK_INITING =
646646
'正在初始化...'
647647
CLI_CHECK_SUCCESS =
648648
'诊断完成,没有发现问题'
649+
CLI_CHECK_PROGRESS = -- TODO: need translate!
650+
'Found {} problems in {} files'
649651
CLI_CHECK_RESULTS =
650652
'诊断完成,共有 {} 个问题,请查看 {}'
651653
CLI_DOC_INITING =

‎locale/zh-tw/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ CLI_CHECK_INITING =
646646
'正在初始化...'
647647
CLI_CHECK_SUCCESS =
648648
'診斷完成,沒有發現問題'
649+
CLI_CHECK_PROGRESS = -- TODO: need translate!
650+
'Found {} problems in {} files'
649651
CLI_CHECK_RESULTS =
650652
'診斷完成,共有 {} 個問題,請查看 {}'
651653
CLI_DOC_INITING = -- TODO: need translate!

‎script/cli/check.lua

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local lclient = require 'lclient'
1+
local lclient = require 'lclient'()
22
local furi = require 'file-uri'
33
local ws = require 'workspace'
44
local files = require 'files'
@@ -41,8 +41,14 @@ util.enableCloseFunction()
4141

4242
local lastClock = os.clock()
4343
local results = {}
44+
45+
local function errorhandler(err)
46+
print(err)
47+
print(debug.traceback())
48+
end
49+
4450
---@async
45-
lclient():start(function (client)
51+
xpcall(lclient.start, errorhandler, lclient, function (client)
4652
client:registerFakers()
4753

4854
client:initialize {
@@ -76,15 +82,27 @@ lclient():start(function (client)
7682
for i, uri in ipairs(uris) do
7783
files.open(uri)
7884
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
8087
lastClock = os.clock()
88+
client:update()
8189
local output = '\x0D'
8290
.. ('>'):rep(math.ceil(i / max * 20))
8391
.. ('='):rep(20 - math.ceil(i / max * 20))
8492
.. ' '
8593
.. ('0'):rep(#tostring(max) - #tostring(i))
8694
.. tostring(i) .. '/' .. tostring(max)
8795
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
88106
io.flush()
89107
end
90108
end

0 commit comments

Comments
 (0)
Please sign in to comment.