@@ -13,7 +13,7 @@ import { IConfirmation, Severity, IChoiceService, IConfirmationResult } from 'vs
1313import { isLinux } from 'vs/base/common/platform' ;
1414import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
1515import { Action } from 'vs/base/common/actions' ;
16- import { IWindowService , IMessageBoxResult } from 'vs/platform/windows/common/windows' ;
16+ import { IWindowService } from 'vs/platform/windows/common/windows' ;
1717import { mnemonicButtonLabel } from 'vs/base/common/labels' ;
1818
1919export class MessageService extends WorkbenchMessageService implements IChoiceService {
@@ -27,31 +27,22 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
2727 }
2828
2929 public confirmWithCheckbox ( confirmation : IConfirmation ) : TPromise < IConfirmationResult > {
30- const opts = this . getConfirmOptions ( confirmation ) ;
31-
32- return this . showMessageBoxWithCheckbox ( opts ) . then ( result => {
33- return {
34- confirmed : result . button === 0 ? true : false ,
35- checkboxChecked : result . checkboxChecked
36- } as IConfirmationResult ;
37- } ) ;
38- }
39-
40- private showMessageBoxWithCheckbox ( opts : Electron . MessageBoxOptions ) : TPromise < IMessageBoxResult > {
41- opts = this . massageMessageBoxOptions ( opts ) ;
30+ const opts = this . massageMessageBoxOptions ( this . getConfirmOptions ( confirmation ) ) ;
4231
4332 return this . windowService . showMessageBox ( opts ) . then ( result => {
33+ const button = isLinux ? opts . buttons . length - result . button - 1 : result . button ;
34+
4435 return {
45- button : isLinux ? opts . buttons . length - result . button - 1 : result . button ,
36+ confirmed : button === 0 ? true : false ,
4637 checkboxChecked : result . checkboxChecked
47- } as IMessageBoxResult ;
38+ } as IConfirmationResult ;
4839 } ) ;
4940 }
5041
5142 public confirm ( confirmation : IConfirmation ) : TPromise < boolean > {
5243 const opts = this . getConfirmOptions ( confirmation ) ;
5344
54- return this . showMessageBox ( opts ) . then ( result => result === 0 ? true : false ) ;
45+ return this . doShowMessageBox ( opts ) . then ( result => result === 0 ? true : false ) ;
5546 }
5647
5748 private getConfirmOptions ( confirmation : IConfirmation ) : Electron . MessageBoxOptions {
@@ -94,16 +85,25 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
9485
9586 public choose ( severity : Severity , message : string , options : string [ ] , cancelId : number , modal : boolean = false ) : TPromise < number > {
9687 if ( modal ) {
97- const type : 'none' | 'info' | 'error' | 'question' | 'warning' = severity === Severity . Info ? 'question' : severity === Severity . Error ? 'error' : severity === Severity . Warning ? 'warning' : 'none' ;
98-
99- return this . showMessageBox ( { message, buttons : options , type, cancelId } ) ;
88+ return this . doChooseModal ( severity , message , options , cancelId ) ;
10089 }
10190
91+ return this . doChooseWithMessage ( severity , message , options ) ;
92+ }
93+
94+ private doChooseModal ( severity : Severity , message : string , options : string [ ] , cancelId : number ) : TPromise < number > {
95+ const type : 'none' | 'info' | 'error' | 'question' | 'warning' = severity === Severity . Info ? 'question' : severity === Severity . Error ? 'error' : severity === Severity . Warning ? 'warning' : 'none' ;
96+
97+ return this . doShowMessageBox ( { message, buttons : options , type, cancelId } ) ;
98+ }
99+
100+ private doChooseWithMessage ( severity : Severity , message : string , options : string [ ] ) : TPromise < number > {
102101 let onCancel : ( ) => void = null ;
103102
104103 const promise = new TPromise < number > ( ( c , e ) => {
105104 const callback = ( index : number ) => ( ) => {
106105 c ( index ) ;
106+
107107 return TPromise . as ( true ) ;
108108 } ;
109109
@@ -115,7 +115,7 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
115115 return promise ;
116116 }
117117
118- private showMessageBox ( opts : Electron . MessageBoxOptions ) : TPromise < number > {
118+ private doShowMessageBox ( opts : Electron . MessageBoxOptions ) : TPromise < number > {
119119 opts = this . massageMessageBoxOptions ( opts ) ;
120120
121121 return this . windowService . showMessageBox ( opts ) . then ( result => isLinux ? opts . buttons . length - result . button - 1 : result . button ) ;
0 commit comments