File tree Expand file tree Collapse file tree
lua/telescope/_extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,13 +12,46 @@ A.gh_pr_checkout = function(prompt_bufnr)
1212 if vim .tbl_isempty (tmp_table ) then
1313 return
1414 end
15+
16+ local qf_entry = {{
17+ text = " Checking out pull request #" .. tmp_table [1 ] .. " , please wait ..."
18+ }}
19+
20+ local on_output = function (_ , line )
21+ table.insert (qf_entry ,{
22+ text = line
23+ })
24+ pcall (vim .schedule_wrap ( function ()
25+ vim .fn .setqflist (qf_entry ," r" )
26+ end ))
27+ end
28+
1529 local job = Job :new ({
1630 enable_recording = true ,
1731 command = " gh" ,
18- args = {" pr" , " checkout" ,tmp_table [1 ]}
32+ args = {" pr" , " checkout" ,tmp_table [1 ]},
33+ on_stdout = on_output ,
34+ on_stderr = on_output ,
35+
36+ on_exit = function (_ ,status )
37+ if status == 0 then
38+ pcall (vim .schedule_wrap ( function ()
39+ vim .cmd [[ cclose]]
40+ end ))
41+ print (" Pull request completed" )
42+ end
43+ end ,
1944 })
20- -- need to display result in quickfix
21- job :sync ()
45+
46+ vim .fn .setqflist (qf_entry ," r" )
47+ vim .cmd [[ copen]]
48+ local timer = vim .loop .new_timer ()
49+ timer :start (200 , 0 , vim .schedule_wrap (function ()
50+ -- increase timeout to 10000ms and wait interval to 20
51+ -- default value is 5000ms and 10
52+ job :sync (10000 ,20 )
53+ end ))
54+
2255end
2356
2457
You can’t perform that action at this time.
0 commit comments