@@ -550,7 +550,7 @@ define(function (require, exports, module) {
550550 } ) ;
551551
552552 // Uncomment - remove prefix and suffix.
553- } else {
553+ } else if ( prefixPos ) {
554554 // Find if the prefix and suffix are at the ch 0 and if they are the only thing in the line.
555555 // If both are found we assume that a complete line selection comment added new lines, so we remove them.
556556 var line = doc . getLine ( prefixPos . line ) . trim ( ) ,
@@ -634,6 +634,11 @@ define(function (require, exports, module) {
634634 return _getBlockCommentPrefixSuffixEdit ( editor , prefix , suffix , [ ] , sel , lineSel . selectionsToTrack , command ) ;
635635 }
636636
637+ function _languageHasCommentsDefined ( editor ) {
638+ const language = editor . document . getLanguage ( ) ;
639+ return language && ( language . hasLineCommentSyntax ( ) || language . hasBlockCommentSyntax ( ) ) ;
640+ }
641+
637642 /**
638643 * @private
639644 * Generates an array of edits for toggling line comments on the given selections.
@@ -684,6 +689,11 @@ define(function (require, exports, module) {
684689 return ;
685690 }
686691
692+ if ( ! _languageHasCommentsDefined ( editor ) ) {
693+ editor . _toggleComment ( ) ;
694+ return ;
695+ }
696+
687697 editor . setSelections ( editor . document . doMultipleEdits ( _getLineCommentEdits ( editor , editor . getSelections ( ) , "line" ) ) ) ;
688698 }
689699
@@ -697,6 +707,11 @@ define(function (require, exports, module) {
697707 return ;
698708 }
699709
710+ if ( ! _languageHasCommentsDefined ( editor ) ) {
711+ editor . _toggleComment ( ) ;
712+ return ;
713+ }
714+
700715 var edits = [ ] ,
701716 lineCommentSels = [ ] ;
702717 _ . each ( editor . getSelections ( ) , function ( sel ) {
0 commit comments