@@ -23,56 +23,42 @@ export class CheckboxQuickPick {
23
23
}
24
24
25
25
private static showInner (
26
- tempOptions : CheckboxQuickPickItem [ ] ,
27
- callback : ( options : CheckboxQuickPickItem [ ] ) => void ) : void {
26
+ items : CheckboxQuickPickItem [ ] ,
27
+ callback : ( items : CheckboxQuickPickItem [ ] ) => void ) : void {
28
28
vscode . window . showQuickPick (
29
- CheckboxQuickPick . getQuickPickItems ( tempOptions ) ,
29
+ CheckboxQuickPick . getQuickPickItems ( items ) ,
30
30
{ ignoreFocusOut : true , placeHolder : CheckboxQuickPick . confirmPlaceHolder } ) . then ( ( selection ) => {
31
31
if ( ! selection ) {
32
32
return ;
33
33
}
34
34
35
35
if ( selection . label === CheckboxQuickPick . confirm ) {
36
- callback ( tempOptions ) ;
36
+ callback ( items ) ;
37
37
return ;
38
38
}
39
39
40
- let index : number = CheckboxQuickPick . getRuleIndex ( tempOptions , selection . description ) ;
41
- CheckboxQuickPick . toggleOption ( tempOptions [ index ] ) ;
42
- CheckboxQuickPick . showInner ( tempOptions , callback ) ;
40
+ let index : number = CheckboxQuickPick . getRuleIndex ( items , selection . description ) ;
41
+ CheckboxQuickPick . toggleSelection ( items [ index ] ) ;
42
+ CheckboxQuickPick . showInner ( items , callback ) ;
43
43
} ) ;
44
44
}
45
45
46
- private static getRuleIndex ( options : CheckboxQuickPickItem [ ] , optionLabel : string ) : number {
47
- return options . findIndex ( opt => opt . name == optionLabel ) ;
46
+ private static getRuleIndex ( items : CheckboxQuickPickItem [ ] , itemLabel : string ) : number {
47
+ return items . findIndex ( item => item . name === itemLabel ) ;
48
48
}
49
49
50
- private static getQuickPickItems ( tempOptions : CheckboxQuickPickItem [ ] ) : QuickPickItem [ ] {
50
+ private static getQuickPickItems ( items : CheckboxQuickPickItem [ ] ) : QuickPickItem [ ] {
51
51
let quickPickItems : QuickPickItem [ ] = [ ] ;
52
52
quickPickItems . push ( { label : CheckboxQuickPick . confirm , description : "Confirm" } ) ;
53
- tempOptions . forEach ( option =>
53
+ items . forEach ( item =>
54
54
quickPickItems . push ( {
55
- label : CheckboxQuickPick . convertToCheckBox ( option . isSelected ) , description : option . name
55
+ label : CheckboxQuickPick . convertToCheckBox ( item . isSelected ) , description : item . name
56
56
} ) ) ;
57
57
return quickPickItems ;
58
58
}
59
59
60
- private static convertToState ( checkBox : string ) : boolean {
61
- return checkBox === CheckboxQuickPick . checkboxOn ;
62
- }
63
-
64
- private static toggleState ( state : boolean ) : boolean {
65
- return ! state ;
66
- }
67
-
68
- private static toggleOption ( option : CheckboxQuickPickItem ) : void {
69
- option . isSelected = CheckboxQuickPick . toggleState ( option . isSelected ) ;
70
- }
71
-
72
- private static toggleCheckBox ( checkBox : string ) : string {
73
- return CheckboxQuickPick . convertToCheckBox (
74
- CheckboxQuickPick . toggleState (
75
- CheckboxQuickPick . convertToState ( checkBox ) ) ) ;
60
+ private static toggleSelection ( item : CheckboxQuickPickItem ) : void {
61
+ item . isSelected = ! item . isSelected ;
76
62
}
77
63
78
64
private static convertToCheckBox ( state : boolean ) : string {
0 commit comments