File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 4444 }
4545 } ) ;
4646
47+ // Rough heuristic to try and detect lines that are part of multi-line string
48+ function probablyInsideString ( cm , pos , line ) {
49+ return / \b s t r i n g \b / . test ( cm . getTokenTypeAt ( Pos ( pos . line , 0 ) ) ) && ! / ^ [ \' \" ` ] / . test ( line )
50+ }
51+
4752 CodeMirror . defineExtension ( "lineComment" , function ( from , to , options ) {
4853 if ( ! options ) options = noOptions ;
4954 var self = this , mode = self . getModeAt ( from ) ;
55+ var firstLine = self . getLine ( from . line ) ;
56+ if ( firstLine == null || probablyInsideString ( self , from , firstLine ) ) return ;
57+
5058 var commentString = options . lineComment || mode . lineComment ;
5159 if ( ! commentString ) {
5260 if ( options . blockCommentStart || mode . blockCommentStart ) {
5563 }
5664 return ;
5765 }
58- var firstLine = self . getLine ( from . line ) ;
59- if ( firstLine == null ) return ;
66+
6067 var end = Math . min ( to . ch != 0 || to . line == from . line ? to . line + 1 : to . line , self . lastLine ( ) + 1 ) ;
6168 var pad = options . padding == null ? " " : options . padding ;
6269 var blankLines = options . commentBlankLines || from . line == to . line ;
You can’t perform that action at this time.
0 commit comments