@@ -3,7 +3,7 @@ local uv = vim.uv or vim.loop
33local start_time = uv .hrtime ()
44
55--- @class Gitsigns.log
6- --- @field private messages [number , string , string , string][]
6+ --- @field private messages [number , string , string , thread ?, string][]
77local M = {
88 debug_mode = false ,
99 verbose = false ,
@@ -94,7 +94,8 @@ local function cprint(kind, lvl, ...)
9494 if ctx .bufnr then
9595 ctx1 = string.format (' %s(%s)' , ctx1 , ctx .bufnr )
9696 end
97- table.insert (M .messages , { time , kind , ctx1 , msg })
97+ local thread = coroutine.running ()
98+ table.insert (M .messages , { time , kind , ctx1 , thread , msg })
9899end
99100
100101function M .dprint (...)
@@ -131,7 +132,8 @@ local function eprint(msg, level)
131132 local info = debug.getinfo (level + 2 , ' Sl' )
132133 local ctx = info and string.format (' %s<%d>' , info .short_src , info .currentline ) or ' ???'
133134 local time = (uv .hrtime () - start_time ) / 1e6
134- table.insert (M .messages , { time , ' error' , ctx , debug.traceback (msg ) })
135+ local thread = coroutine.running ()
136+ table.insert (M .messages , { time , ' error' , ctx , thread , debug.traceback (msg ) })
135137 if M .debug_mode then
136138 error (msg , 3 )
137139 end
@@ -167,18 +169,39 @@ function M.clear()
167169 M .messages = {}
168170end
169171
170- --- @param m [number , string , string , string]
172+ --- @param thread thread
173+ --- @return string
174+ local function fmt_thread (thread )
175+ local threads = _G .tostring (thread )
176+ local thread1 = threads :sub (# threads - 1 )
177+ return ' <t:' .. thread1 .. ' >'
178+ end
179+
180+ --- @param m [number , string , string , thread , string]
171181--- @return [string,string][]
172182local function build_msg (m )
173- local time , kind , ctx , msg = m [1 ], m [2 ], m [3 ], m [4 ]
183+ local time , kind , ctx , thread , msg = m [1 ], m [2 ], m [3 ], m [4 ], m [ 5 ]
174184 local hl = sev_to_hl [kind ]
175- return {
185+
186+ local r = {
176187 { string.format (' %.2f ' , time ), ' Comment' },
188+ }
189+
190+ if thread then
191+ vim .list_extend (r , {
192+ { fmt_thread (thread ), ' Comment' },
193+ { ' ' },
194+ })
195+ end
196+
197+ vim .list_extend (r , {
177198 { kind :upper ():sub (1 , 1 ), hl },
178199 { string.format (' %s:' , ctx ), ' Tag' },
179200 { ' ' },
180- { msg },
181- }
201+ { msg }
202+ })
203+
204+ return r
182205end
183206
184207function M .show ()
0 commit comments