1
+ import type { IWorktree } from '#/@types/worktree' ;
1
2
import { removeBranch , throwIfNotInWorktreeRepository } from '#/helpers/git' ;
3
+ import { ProgressLocation , window } from 'vscode' ;
2
4
import settings from '../config/settings' ;
3
5
import { raiseIssue , showUserMessage } from '../helpers/vscode' ;
4
6
import { getWorktrees } from '../helpers/worktree/getWorktrees' ;
@@ -24,8 +26,38 @@ export const remove = async () => {
24
26
if ( ! Array . isArray ( selectedWorktrees ) )
25
27
selectedWorktrees = [ selectedWorktrees ] ;
26
28
27
- await Promise . all (
28
- selectedWorktrees . map ( ( worktree ) => removeWorktree ( worktree ) )
29
+ await window . withProgress (
30
+ {
31
+ location : ProgressLocation . Window ,
32
+ title : 'Removing Worktrees' ,
33
+ cancellable : false ,
34
+ } ,
35
+ async ( progress ) => {
36
+ const worktrees = selectedWorktrees as IWorktree [ ] ;
37
+
38
+ let percentProgress = 0 ;
39
+ let incrementBy = 100 / worktrees . length ;
40
+
41
+ progress . report ( { increment : percentProgress } ) ;
42
+
43
+ return Promise . all (
44
+ worktrees . map ( async ( worktree ) => {
45
+ await removeWorktree ( worktree ) ;
46
+
47
+ percentProgress += incrementBy ;
48
+
49
+ const currentlyRemoved = (
50
+ worktrees . length -
51
+ ( 100 - percentProgress ) / incrementBy
52
+ ) . toFixed ( ) ;
53
+
54
+ progress . report ( {
55
+ increment : percentProgress ,
56
+ message : `${ currentlyRemoved } /${ worktrees . length } ` ,
57
+ } ) ;
58
+ } )
59
+ ) ;
60
+ }
29
61
) ;
30
62
31
63
if ( settings . shouldRemoveBranch )
0 commit comments