@@ -10,7 +10,6 @@ class Bootstrapper {
1010 initiate ( context ) {
1111 this . _registerProviders ( context )
1212 this . _registerCommands ( context )
13- this . _registerEditorCommands ( context )
1413 }
1514
1615 _registerProviders ( context ) {
@@ -22,37 +21,43 @@ class Bootstrapper {
2221 }
2322
2423 _registerCommands ( context ) {
25- const command = this . _commandFactory . createCompareVisibleEditorsCommand ( )
26- const disposable = this . _vscode . commands . registerCommand (
27- `${ EXTENSION_NAMESPACE } .diffVisibleEditors` ,
28- command . execute ,
29- command
30- )
31- context . subscriptions . push ( disposable )
32- }
33-
34- _registerEditorCommands ( context ) {
35- const factory = this . _commandFactory
36- const commandMap = new Map ( [
37- [ `${ EXTENSION_NAMESPACE } .markSection1` , factory . crateSaveText1Command ( ) ] ,
38- [
39- `${ EXTENSION_NAMESPACE } .markSection2AndTakeDiff` ,
40- factory . createCompareSelectionWithText1Command ( )
41- ] ,
42- [
43- `${ EXTENSION_NAMESPACE } .diffSelectionWithClipboard` ,
44- factory . createCompareSelectionWithClipboardCommand ( )
45- ]
46- ] )
47- commandMap . forEach ( ( command , commandName ) => {
48- const disposable = this . _vscode . commands . registerTextEditorCommand (
49- commandName ,
50- command . execute ,
51- command
52- )
24+ this . _commandList . forEach ( command => {
25+ const registerer = this . _getCommandRegisterer ( command . type )
26+ const disposable = registerer ( command . name , command . command . execute , command . command )
5327 context . subscriptions . push ( disposable )
5428 } )
5529 }
30+
31+ _getCommandRegisterer ( commandType ) {
32+ return commandType === 'TEXT_EDITOR'
33+ ? this . _vscode . commands . registerTextEditorCommand
34+ : this . _vscode . commands . registerCommand
35+ }
36+
37+ get _commandList ( ) {
38+ return [
39+ {
40+ name : `${ EXTENSION_NAMESPACE } .diffVisibleEditors` ,
41+ type : 'GENERAL' ,
42+ command : this . _commandFactory . createCompareVisibleEditorsCommand ( )
43+ } ,
44+ {
45+ name : `${ EXTENSION_NAMESPACE } .markSection1` ,
46+ type : 'TEXT_EDITOR' ,
47+ command : this . _commandFactory . crateSaveText1Command ( )
48+ } ,
49+ {
50+ name : `${ EXTENSION_NAMESPACE } .markSection2AndTakeDiff` ,
51+ type : 'TEXT_EDITOR' ,
52+ command : this . _commandFactory . createCompareSelectionWithText1Command ( )
53+ } ,
54+ {
55+ name : `${ EXTENSION_NAMESPACE } .diffSelectionWithClipboard` ,
56+ type : 'TEXT_EDITOR' ,
57+ command : this . _commandFactory . createCompareSelectionWithClipboardCommand ( )
58+ }
59+ ]
60+ }
5661}
5762
5863module . exports = Bootstrapper
0 commit comments