@@ -11,6 +11,7 @@ import nls = require('vs/nls');
1111import { format } from 'vs/base/common/strings' ;
1212import lifecycle = require( 'vs/base/common/lifecycle' ) ;
1313import schedulers = require( 'vs/base/common/async' ) ;
14+ import Severity from 'vs/base/common/severity' ;
1415import dom = require( 'vs/base/browser/dom' ) ;
1516import errors = require( 'vs/base/common/errors' ) ;
1617import EditorBrowser = require( 'vs/editor/browser/editorBrowser' ) ;
@@ -21,6 +22,7 @@ import referenceSearch = require('vs/editor/contrib/referenceSearch/browser/refe
2122import { IModelService } from 'vs/editor/common/services/modelService' ;
2223import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2324import { IKeybindingService } from 'vs/platform/keybinding/common/keybindingService' ;
25+ import { IMessageService } from 'vs/platform/message/common/message' ;
2426import { Range } from 'vs/editor/common/core/range' ;
2527import { CodeLensRegistry , ICodeLensData , getCodeLensData } from '../common/codelens' ;
2628
@@ -61,7 +63,7 @@ class CodeLensContentWidget implements EditorBrowser.IContentWidget {
6163 private _commands : { [ id : string ] : Modes . ICommand } = Object . create ( null ) ;
6264
6365 public constructor ( editor : EditorBrowser . ICodeEditor , symbolRange : EditorCommon . IEditorRange ,
64- keybindingService : IKeybindingService ) {
66+ keybindingService : IKeybindingService , messageService : IMessageService ) {
6567
6668 this . _id = 'codeLensWidget' + ( ++ CodeLensContentWidget . ID ) ;
6769 this . _editor = editor ;
@@ -79,7 +81,9 @@ class CodeLensContentWidget implements EditorBrowser.IContentWidget {
7981 let command = this . _commands [ element . id ] ;
8082 if ( command ) {
8183 editor . focus ( ) ;
82- keybindingService . executeCommand ( command . id , command . arguments ) ;
84+ keybindingService . executeCommand ( command . id , command . arguments ) . done ( undefined , err => {
85+ messageService . show ( Severity . Error , err ) ;
86+ } ) ;
8387 }
8488 }
8589 } ) ;
@@ -226,7 +230,7 @@ class CodeLens {
226230 public constructor ( data : ICodeLensData [ ] , editor : EditorBrowser . ICodeEditor ,
227231 helper : CodeLensHelper ,
228232 viewZoneChangeAccessor : EditorBrowser . IViewZoneChangeAccessor ,
229- keybindingService : IKeybindingService ) {
233+ keybindingService : IKeybindingService , messageService : IMessageService ) {
230234
231235 this . _editor = editor ;
232236 this . _data = data ;
@@ -251,7 +255,7 @@ class CodeLens {
251255 } ) ;
252256
253257 this . _viewZone = new CodeLensViewZone ( range . startLineNumber - 1 ) ;
254- this . _contentWidget = new CodeLensContentWidget ( editor , Range . lift ( range ) , keybindingService ) ;
258+ this . _contentWidget = new CodeLensContentWidget ( editor , Range . lift ( range ) , keybindingService , messageService ) ;
255259
256260 this . _viewZoneId = viewZoneChangeAccessor . addZone ( this . _viewZone ) ;
257261 this . _editor . addContentWidget ( this . _contentWidget ) ;
@@ -343,19 +347,22 @@ export class CodeLensContribution implements EditorCommon.IEditorContribution {
343347 private _modelChangeCounter : number ;
344348 private _configurationService : IConfigurationService ;
345349 private _keybindingService : IKeybindingService ;
350+ private _messageService : IMessageService ;
346351 private _codeLenseDisabledByMode : boolean ;
347352
348353 private _currentFindOccPromise :TPromise < any > ;
349354
350355 constructor ( editor : EditorBrowser . ICodeEditor , @IModelService modelService : IModelService ,
351356 @IConfigurationService configurationService : IConfigurationService ,
352- @IKeybindingService keybindingService : IKeybindingService ) {
357+ @IKeybindingService keybindingService : IKeybindingService ,
358+ @IMessageService messageService : IMessageService ) {
353359
354360 this . _instanceCount = ( ++ CodeLensContribution . INSTANCE_COUNT ) ;
355361 this . _editor = editor ;
356362 this . _modelService = modelService ;
357363 this . _configurationService = configurationService ;
358364 this . _keybindingService = keybindingService ;
365+ this . _messageService = messageService ;
359366
360367 this . _globalToDispose = [ ] ;
361368 this . _localToDispose = [ ] ;
@@ -553,7 +560,7 @@ export class CodeLensContribution implements EditorCommon.IEditorContribution {
553560 groupsIndex ++ ;
554561 codeLensIndex ++ ;
555562 } else {
556- this . _lenses . splice ( codeLensIndex , 0 , new CodeLens ( groups [ groupsIndex ] , this . _editor , helper , accessor , this . _keybindingService ) ) ;
563+ this . _lenses . splice ( codeLensIndex , 0 , new CodeLens ( groups [ groupsIndex ] , this . _editor , helper , accessor , this . _keybindingService , this . _messageService ) ) ;
557564 codeLensIndex ++ ;
558565 groupsIndex ++ ;
559566 }
@@ -567,7 +574,7 @@ export class CodeLensContribution implements EditorCommon.IEditorContribution {
567574
568575 // Create extra symbols
569576 while ( groupsIndex < groups . length ) {
570- this . _lenses . push ( new CodeLens ( groups [ groupsIndex ] , this . _editor , helper , accessor , this . _keybindingService ) ) ;
577+ this . _lenses . push ( new CodeLens ( groups [ groupsIndex ] , this . _editor , helper , accessor , this . _keybindingService , this . _messageService ) ) ;
571578 groupsIndex ++ ;
572579 }
573580
0 commit comments