lib/action/lineBreaks.js
function(editor) {
			var info = editorUtils.outputInfo(editor);
			var caretPos = editor.getCaretPos();
			var nl = '\n';
			var pad = '\t';
			
			if (~xmlSyntaxes.indexOf(info.syntax)) {
				// let's see if we're breaking newly created tag
				var tag = htmlMatcher.tag(info.content, caretPos);
				if (tag && !tag.innerRange.length()) {
					editor.replaceContent(nl + pad + utils.getCaretPlaceholder() + nl, caretPos);
					return true;
				}
			} else if (info.syntax == 'css') {
				/** @type String */
				var content = info.content;
				if (caretPos && content.charAt(caretPos - 1) == '{') {
					var append = prefs.get('css.closeBraceIndentation');
					
					var hasCloseBrace = content.charAt(caretPos) == '}';
					if (!hasCloseBrace) {
						// do we really need special formatting here?
						// check if this is really a newly created rule,
						// look ahead for a closing brace
						for (var i = caretPos, il = content.length, ch; i < il; i++) {
							ch = content.charAt(i);
							if (ch == '{') {
								// ok, this is a new rule without closing brace
								break;
							}
							
							if (ch == '}') {
								// not a new rule, just add indentation
								append = '';
								hasCloseBrace = true;
								break;
							}
						}
					}
					
					if (!hasCloseBrace) {
						append += '}';
					}
					
					// defining rule set
					var insValue = nl + pad + utils.getCaretPlaceholder() + append;
					editor.replaceContent(insValue, caretPos);
					return true;
				}
			}
				
			return false;
		}
function(editor) {
			var info = editorUtils.outputInfo(editor);
			var caretPos = editor.getCaretPos();
			var nl = '\n';
			var pad = '\t';
			
			if (~xmlSyntaxes.indexOf(info.syntax)) {
				// let's see if we're breaking newly created tag
				var tag = htmlMatcher.tag(info.content, caretPos);
				if (tag && !tag.innerRange.length()) {
					editor.replaceContent(nl + pad + utils.getCaretPlaceholder() + nl, caretPos);
					return true;
				}
			} else if (info.syntax == 'css') {
				/** @type String */
				var content = info.content;
				if (caretPos && content.charAt(caretPos - 1) == '{') {
					var append = prefs.get('css.closeBraceIndentation');
					
					var hasCloseBrace = content.charAt(caretPos) == '}';
					if (!hasCloseBrace) {
						// do we really need special formatting here?
						// check if this is really a newly created rule,
						// look ahead for a closing brace
						for (var i = caretPos, il = content.length, ch; i < il; i++) {
							ch = content.charAt(i);
							if (ch == '{') {
								// ok, this is a new rule without closing brace
								break;
							}
							
							if (ch == '}') {
								// not a new rule, just add indentation
								append = '';
								hasCloseBrace = true;
								break;
							}
						}
					}
					
					if (!hasCloseBrace) {
						append += '}';
					}
					
					// defining rule set
					var insValue = nl + pad + utils.getCaretPlaceholder() + append;
					editor.replaceContent(insValue, caretPos);
					return true;
				}
			}
				
			return false;
		}
function ( editor ) { var info = editorUtils . outputInfo ( editor ) ; var caretPos = editor . getCaretPos ( ) ; var nl = '\n' ; var pad = '\t' ; if ( ~ xmlSyntaxes . indexOf ( info . syntax ) ) { // let's see if we're breaking newly created tag var tag = htmlMatcher . tag ( info . content , caretPos ) ; if ( tag && ! tag . innerRange . length ( ) ) { editor . replaceContent ( nl + pad + utils . getCaretPlaceholder ( ) + nl , caretPos ) ; return true ; } } else if ( info . syntax == 'css' ) { /** @type String */ var content = info . content ; if ( caretPos && content . charAt ( caretPos - 1 ) == '{' ) { var append = prefs . get ( 'css.closeBraceIndentation' ) ; var hasCloseBrace = content . charAt ( caretPos ) == '}' ; if ( ! hasCloseBrace ) { // do we really need special formatting here? // check if this is really a newly created rule, // look ahead for a closing brace for ( var i = caretPos , il = content . length , ch ; i < il ; i ++ ) { ch = content . charAt ( i ) ; if ( ch == '{' ) { // ok, this is a new rule without closing brace break ; } if ( ch == '}' ) { // not a new rule, just add indentation append = '' ; hasCloseBrace = true ; break ; } } } if ( ! hasCloseBrace ) { append += '}' ; } // defining rule set var insValue = nl + pad + utils . getCaretPlaceholder ( ) + append ; editor . replaceContent ( insValue , caretPos ) ; return true ; } } return false ; }
Inserts newline character with proper indentation in specific positions only.
@param {IEmmetEditor} editor
@return {Boolean} Returns <code>true</code> if line break was inserted
Inserts newline character with proper indentation in specific positions only .