bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
function(openBracket, closeBracket) {
			if (openBracket === "[" && !this.autoPairSquareBrackets) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "{" && !this.autoPairBraces) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "(" && !this.autoPairParentheses) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "<" && !this.autoPairAngleBrackets) { //$NON-NLS-0$
				return false;
			}

			var editor = this.editor;
			var textView = editor.getTextView();
			if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
			var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
			var model = editor.getModel();
			forEachSelection(this, false, function(selection, setText) {
				var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
				var text;
				if (selection.start === selection.end && isClosingBracket.test(nextChar)) {
					// No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,
					// and maintain the caret position inbetween the brackets
					text = openBracket + closeBracket;
					setText(text, selection.start, selection.start);
					selection.start = selection.end = selection.start + 1;
				} else if (selection.start !== selection.end) {
					// Wrap the selected text with the specified opening and closing brackets and keep selection on text
					text = openBracket + model.getText(selection.start, selection.end) + closeBracket;
					setText(text, selection.start, selection.end);
					selection.start += 1;
					selection.end += 1;
				} else {
					setText(openBracket, selection.start, selection.end);
					selection.start = selection.end = selection.start + openBracket.length;
				}
			});
			return true;
		}
function(openBracket, closeBracket) {
			if (openBracket === "[" && !this.autoPairSquareBrackets) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "{" && !this.autoPairBraces) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "(" && !this.autoPairParentheses) { //$NON-NLS-0$
				return false;
			} else if (openBracket === "<" && !this.autoPairAngleBrackets) { //$NON-NLS-0$
				return false;
			}

			var editor = this.editor;
			var textView = editor.getTextView();
			if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
			var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
			var model = editor.getModel();
			forEachSelection(this, false, function(selection, setText) {
				var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
				var text;
				if (selection.start === selection.end && isClosingBracket.test(nextChar)) {
					// No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,
					// and maintain the caret position inbetween the brackets
					text = openBracket + closeBracket;
					setText(text, selection.start, selection.start);
					selection.start = selection.end = selection.start + 1;
				} else if (selection.start !== selection.end) {
					// Wrap the selected text with the specified opening and closing brackets and keep selection on text
					text = openBracket + model.getText(selection.start, selection.end) + closeBracket;
					setText(text, selection.start, selection.end);
					selection.start += 1;
					selection.end += 1;
				} else {
					setText(openBracket, selection.start, selection.end);
					selection.start = selection.end = selection.start + openBracket.length;
				}
			});
			return true;
		}
function ( openBracket , closeBracket ) { if ( openBracket === "[" && ! this . autoPairSquareBrackets ) { //$NON-NLS-0$
 return false ; } else if ( openBracket === "{" && ! this . autoPairBraces ) { //$NON-NLS-0$
 return false ; } else if ( openBracket === "(" && ! this . autoPairParentheses ) { //$NON-NLS-0$
 return false ; } else if ( openBracket === "<" && ! this . autoPairAngleBrackets ) { //$NON-NLS-0$
 return false ; } var editor = this . editor ; var textView = editor . getTextView ( ) ; if ( textView . getOptions ( "readonly" ) ) { return false ; } //$NON-NLS-0$
 var isClosingBracket = new RegExp ( "^$|[)}\\]>]" ) ; //$NON-NLS-0$ // matches any empty string and closing bracket
 var model = editor . getModel ( ) ; forEachSelection ( this , false , function ( selection , setText ) { var nextChar = ( selection . start === model . getCharCount ( ) ) ? "" : model . getText ( selection . start , selection . start + 1 ) . trim ( ) ; //$NON-NLS-0$
 var text ; if ( selection . start === selection . end && isClosingBracket . test ( nextChar ) ) { // No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,
 // and maintain the caret position inbetween the brackets
 text = openBracket + closeBracket ; setText ( text , selection . start , selection . start ) ; selection . start = selection . end = selection . start + 1 ; } else if ( selection . start !== selection . end ) { // Wrap the selected text with the specified opening and closing brackets and keep selection on text
 text = openBracket + model . getText ( selection . start , selection . end ) + closeBracket ; setText ( text , selection . start , selection . end ) ; selection . start += 1 ; selection . end += 1 ; } else { setText ( openBracket , selection . start , selection . end ) ; selection . start = selection . end = selection . start + openBracket . length ; } } ) ; return true ; }
Called on an opening bracket keypress.
Automatically inserts the specified opening and closing brackets around the caret or selected text.
Called on an opening bracket keypress . Automatically inserts the specified opening and closing brackets around the caret or selected text .