vendor/emmet.js
function genericCommentToggle(editor, commentStart, commentEnd, range) {
		var editorUtils = require('editorUtils');
		var content = editorUtils.outputInfo(editor).content;
		var caretPos = editor.getCaretPos();
		var newContent = null;
		
		var utils = require('utils');
			
		/**
		 * Remove comment markers from string
		 * @param {Sting} str
		 * @return {String}
		 */
		function removeComment(str) {
			return str
				.replace(new RegExp('^' + utils.escapeForRegexp(commentStart) + '\\s*'), function(str){
					caretPos -= str.length;
					return '';
				}).replace(new RegExp('\\s*' + utils.escapeForRegexp(commentEnd) + '$'), '');
		}
		
		// first, we need to make sure that this substring is not inside 
		// comment
		var commentRange = searchComment(content, caretPos, commentStart, commentEnd);
		if (commentRange && commentRange.overlap(range)) {
			// we're inside comment, remove it
			range = commentRange;
			newContent = removeComment(range.substring(content));
		} else {
			// should add comment
			// make sure that there's no comment inside selection
			newContent = commentStart + ' ' +
				range.substring(content)
					.replace(new RegExp(utils.escapeForRegexp(commentStart) + '\\s*|\\s*' + utils.escapeForRegexp(commentEnd), 'g'), '') +
				' ' + commentEnd;
				
			// adjust caret position
			caretPos += commentStart.length + 1;
		}

		// replace editor content
		if (newContent !== null) {
			newContent = utils.escapeText(newContent);
			editor.setCaretPos(range.start);
			editor.replaceContent(editorUtils.unindent(editor, newContent), range.start, range.end);
			editor.setCaretPos(caretPos);
			return true;
		}
		
		return false;
	}
function genericCommentToggle(editor, commentStart, commentEnd, range) {
		var editorUtils = require('editorUtils');
		var content = editorUtils.outputInfo(editor).content;
		var caretPos = editor.getCaretPos();
		var newContent = null;
		
		var utils = require('utils');
			
		/**
		 * Remove comment markers from string
		 * @param {Sting} str
		 * @return {String}
		 */
		function removeComment(str) {
			return str
				.replace(new RegExp('^' + utils.escapeForRegexp(commentStart) + '\\s*'), function(str){
					caretPos -= str.length;
					return '';
				}).replace(new RegExp('\\s*' + utils.escapeForRegexp(commentEnd) + '$'), '');
		}
		
		// first, we need to make sure that this substring is not inside 
		// comment
		var commentRange = searchComment(content, caretPos, commentStart, commentEnd);
		if (commentRange && commentRange.overlap(range)) {
			// we're inside comment, remove it
			range = commentRange;
			newContent = removeComment(range.substring(content));
		} else {
			// should add comment
			// make sure that there's no comment inside selection
			newContent = commentStart + ' ' +
				range.substring(content)
					.replace(new RegExp(utils.escapeForRegexp(commentStart) + '\\s*|\\s*' + utils.escapeForRegexp(commentEnd), 'g'), '') +
				' ' + commentEnd;
				
			// adjust caret position
			caretPos += commentStart.length + 1;
		}

		// replace editor content
		if (newContent !== null) {
			newContent = utils.escapeText(newContent);
			editor.setCaretPos(range.start);
			editor.replaceContent(editorUtils.unindent(editor, newContent), range.start, range.end);
			editor.setCaretPos(caretPos);
			return true;
		}
		
		return false;
	}
function genericCommentToggle ( editor , commentStart , commentEnd , range ) { var editorUtils = require ( 'editorUtils' ) ; var content = editorUtils . outputInfo ( editor ) . content ; var caretPos = editor . getCaretPos ( ) ; var newContent = null ; var utils = require ( 'utils' ) ; /**
		 * Remove comment markers from string
		 * @param {Sting} str
		 * @return {String}
		 */ function removeComment ( str ) { return str . replace ( new RegExp ( '^' + utils . escapeForRegexp ( commentStart ) + '\\s*' ) , function ( str ) { caretPos -= str . length ; return '' ; } ) . replace ( new RegExp ( '\\s*' + utils . escapeForRegexp ( commentEnd ) + '$' ) , '' ) ; } // first, we need to make sure that this substring is not inside  // comment var commentRange = searchComment ( content , caretPos , commentStart , commentEnd ) ; if ( commentRange && commentRange . overlap ( range ) ) { // we're inside comment, remove it range = commentRange ; newContent = removeComment ( range . substring ( content ) ) ; } else { // should add comment // make sure that there's no comment inside selection newContent = commentStart + ' ' + range . substring ( content ) . replace ( new RegExp ( utils . escapeForRegexp ( commentStart ) + '\\s*|\\s*' + utils . escapeForRegexp ( commentEnd ) , 'g' ) , '' ) + ' ' + commentEnd ; // adjust caret position caretPos += commentStart . length + 1 ; } // replace editor content if ( newContent !== null ) { newContent = utils . escapeText ( newContent ) ; editor . setCaretPos ( range . start ) ; editor . replaceContent ( editorUtils . unindent ( editor , newContent ) , range . start , range . end ) ; editor . setCaretPos ( caretPos ) ; return true ; } return false ; }
Generic comment toggling routine
@param {IEmmetEditor} editor
@param {String} commentStart Comment start token
@param {String} commentEnd Comment end token
@param {Range} range Selection range
@return {Boolean}
Generic comment toggling routine