@@ -23,56 +23,42 @@ export class CheckboxQuickPick {
2323 }
2424
2525 private static showInner (
26- tempOptions : CheckboxQuickPickItem [ ] ,
27- callback : ( options : CheckboxQuickPickItem [ ] ) => void ) : void {
26+ items : CheckboxQuickPickItem [ ] ,
27+ callback : ( items : CheckboxQuickPickItem [ ] ) => void ) : void {
2828 vscode . window . showQuickPick (
29- CheckboxQuickPick . getQuickPickItems ( tempOptions ) ,
29+ CheckboxQuickPick . getQuickPickItems ( items ) ,
3030 { ignoreFocusOut : true , placeHolder : CheckboxQuickPick . confirmPlaceHolder } ) . then ( ( selection ) => {
3131 if ( ! selection ) {
3232 return ;
3333 }
3434
3535 if ( selection . label === CheckboxQuickPick . confirm ) {
36- callback ( tempOptions ) ;
36+ callback ( items ) ;
3737 return ;
3838 }
3939
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 ) ;
4343 } ) ;
4444 }
4545
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 ) ;
4848 }
4949
50- private static getQuickPickItems ( tempOptions : CheckboxQuickPickItem [ ] ) : QuickPickItem [ ] {
50+ private static getQuickPickItems ( items : CheckboxQuickPickItem [ ] ) : QuickPickItem [ ] {
5151 let quickPickItems : QuickPickItem [ ] = [ ] ;
5252 quickPickItems . push ( { label : CheckboxQuickPick . confirm , description : "Confirm" } ) ;
53- tempOptions . forEach ( option =>
53+ items . forEach ( item =>
5454 quickPickItems . push ( {
55- label : CheckboxQuickPick . convertToCheckBox ( option . isSelected ) , description : option . name
55+ label : CheckboxQuickPick . convertToCheckBox ( item . isSelected ) , description : item . name
5656 } ) ) ;
5757 return quickPickItems ;
5858 }
5959
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 ;
7662 }
7763
7864 private static convertToCheckBox ( state : boolean ) : string {
0 commit comments