diff --git a/src/ace/Document.js b/src/ace/Document.js index 2d766f5d..ae8b5dc8 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -249,10 +249,21 @@ var Document = function(text, mode) { } }; + /** + * Get a verbatim copy of the given line as it is in the document + */ this.getLine = function(row) { return this.lines[row] || ""; }; + /** + * Get a line as it is displayed on screen. Tabs are replaced by spaces. + */ + this.getDisplayLine = function(row) { + var tab = new Array(this.getTabSize()+1).join(" "); + return this.lines[row].replace(/\t/g, tab); + }; + this.getLines = function(firstRow, lastRow) { return this.lines.slice(firstRow, lastRow+1); }; diff --git a/src/ace/Selection.js b/src/ace/Selection.js index 6f6178ef..89ccea38 100644 --- a/src/ace/Selection.js +++ b/src/ace/Selection.js @@ -281,7 +281,14 @@ var Selection = function(doc) { }; this.moveCursorLineStart = function() { - this.moveCursorTo(this.selectionLead.row, 0); + var row = this.selectionLead.row; + var column = this.selectionLead.column; + var beforeCursor = this.doc.getDisplayLine(row).slice(0, column); + var leadingSpace = beforeCursor.match(/^\s+/); + if (!leadingSpace || leadingSpace[0].length >= column) + this.moveCursorTo(this.selectionLead.row, 0); + else + this.moveCursorTo(this.selectionLead.row, leadingSpace[0].length); }; this.moveCursorLineEnd = function() { diff --git a/src/ace/mode/JavaScriptHighlightRules.js b/src/ace/mode/JavaScriptHighlightRules.js index 3a2d29b1..6b1ede7f 100644 --- a/src/ace/mode/JavaScriptHighlightRules.js +++ b/src/ace/mode/JavaScriptHighlightRules.js @@ -19,8 +19,8 @@ JavaScriptHighlightRules = function() { var docComment = new DocCommentHighlightRules(); var keywords = lang.arrayToMap( - ("break|case|catch|continue|default|delete|do|else|finally|for|function|\ - if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|") + ("break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|") ); var buildinConstants = lang.arrayToMap( @@ -28,8 +28,8 @@ JavaScriptHighlightRules = function() { ); var futureReserved = lang.arrayToMap( - ("class|enum|extends|super|const|export|import|implements|let|private|\ - public|yield|interface|package|protected|static").split("|") + ("class|enum|extends|super|const|export|import|implements|let|private|" + + "public|yield|interface|package|protected|static").split("|") ); // regexp must not have capturing parentheses. Use (?:) instead. diff --git a/src/ace/theme/tm.css b/src/ace/theme/tm.css index 2f7cdd73..be5ef74f 100644 --- a/src/ace/theme/tm.css +++ b/src/ace/theme/tm.css @@ -1,7 +1,7 @@ .ace-tm .ace_editor { border: 2px solid rgb(159, 159, 159); font-family: "Menlo", "Monaco", "Courier New", "Courier", monospace; - font-size: 12px; + font-size: 11px; } .ace-tm .ace_editor.ace_focus { @@ -12,8 +12,8 @@ width: 50px; background: #e8e8e8; color: #333; - font-family: Menlo, Monaco, "Courier New"; - font-size: 12px; + font-family: "Menlo", "Monaco", "Courier New", monospace; + font-size: 11px; overflow : hidden; }