@@ -47,6 +47,7 @@ import { IAccessibilityService } from '../../../../platform/accessibility/common
47
47
import { URI } from '../../../../base/common/uri.js' ;
48
48
import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js' ;
49
49
import { threadHasMeaningfulComments } from './commentsModel.js' ;
50
+ import { INotificationService } from '../../../../platform/notification/common/notification.js' ;
50
51
51
52
export const ID = 'editor.contrib.review' ;
52
53
@@ -485,7 +486,8 @@ export class CommentController implements IEditorContribution {
485
486
@IContextKeyService contextKeyService : IContextKeyService ,
486
487
@IEditorService private readonly editorService : IEditorService ,
487
488
@IKeybindingService private readonly keybindingService : IKeybindingService ,
488
- @IAccessibilityService private readonly accessibilityService : IAccessibilityService
489
+ @IAccessibilityService private readonly accessibilityService : IAccessibilityService ,
490
+ @INotificationService private readonly notificationService : INotificationService
489
491
) {
490
492
this . _commentInfos = [ ] ;
491
493
this . _commentWidgets = [ ] ;
@@ -1168,7 +1170,11 @@ export class CommentController implements IEditorContribution {
1168
1170
if ( ! newCommentInfos . length || ! this . editor ?. hasModel ( ) ) {
1169
1171
this . _addInProgress = false ;
1170
1172
if ( ! newCommentInfos . length ) {
1171
- throw new Error ( `There are no commenting ranges at the current position (${ range ? 'with range' : 'without range' } ).` ) ;
1173
+ if ( range ) {
1174
+ this . notificationService . error ( nls . localize ( 'comments.addCommand.error' , "The cursor must be within a commenting range to add a comment." ) ) ;
1175
+ } else {
1176
+ this . notificationService . error ( nls . localize ( 'comments.addFileCommentCommand.error' , "File comments are not allowed on this file." ) ) ;
1177
+ }
1172
1178
}
1173
1179
return Promise . resolve ( ) ;
1174
1180
}
0 commit comments