@@ -46,42 +46,6 @@ function M.at(params)
4646 return info and (info .kind or M .Kind .processing )
4747end
4848
49- --- Like `at`, but also returns processing if the file has processing
50- --- ranges that haven't reached the given position yet.
51- --- This is needed when e.g. imports are building and the cursor is on a
52- --- later line that hasn't been reached yet.
53- --- @param params lsp.TextDocumentPositionParams
54- --- @return LeanFileProgressKind ? kind
55- function M .at_or_file (params )
56- local infos = M .proc_infos [params .textDocument .uri ]
57- if not infos then
58- return M .Kind .processing
59- end
60- if # infos == 0 then
61- return
62- end
63-
64- local line = params .position .line
65- --- @type LeanFileProgressProcessingInfo ?
66- local info = vim .iter (infos ):find (function (each )
67- return (line >= each .range .start .line ) and (line <= each .range [' end' ].line )
68- end )
69- if info then
70- return info .kind or M .Kind .processing
71- end
72-
73- -- Cursor is not in any processing range. If processing hasn't reached
74- -- the cursor yet (cursor is past all ranges), treat as processing.
75- -- Lean processes top-to-bottom, so this means the cursor's line is
76- -- waiting for earlier lines (e.g. imports) to finish.
77- local max_end = vim .iter (infos ):fold (- 1 , function (acc , each )
78- return math.max (acc , each .range [' end' ].line )
79- end )
80- if line > max_end then
81- return M .Kind .processing
82- end
83- end
84-
8549--- Calculate the percentage of a buffer which finished processing.
8650--- @param bufnr ? number the buffer number , defaulting to 0
8751--- @return number the percentage of *finished* lines as a number from 0 to 100
0 commit comments