diff --git a/lib/ace/ext/themelist.js b/lib/ace/ext/themelist.js index 2bb39b3c..9eb4b71e 100644 --- a/lib/ace/ext/themelist.js +++ b/lib/ace/ext/themelist.js @@ -30,8 +30,6 @@ * * ***** END LICENSE BLOCK ***** */ -/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ -/*global define, require */ /** * Generates a list of themes available when ace was built. @@ -77,7 +75,7 @@ var themeData = [ ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], ["Twilight" ,"twilight" , "dark"], ["Vibrant Ink" ,"vibrant_ink" , "dark"] -] +]; exports.themesByName = {}; @@ -88,10 +86,10 @@ exports.themesByName = {}; exports.themes = themeData.map(function(data) { var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); var theme = { - caption: data[0], - theme: "ace/theme/" + name, - isDark: data[2] == "dark", - name: name + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name }; exports.themesByName[name] = theme; return theme; diff --git a/lib/ace/ext/whitespace.js b/lib/ace/ext/whitespace.js index 83486fb0..cbbdbb43 100644 --- a/lib/ace/ext/whitespace.js +++ b/lib/ace/ext/whitespace.js @@ -64,6 +64,9 @@ exports.$detectIndentation = function(lines, fallback) { while (line[line.length - 1] == "\\") line = lines[i++]; } + + if (!stats.length) + return; function getScore(indent) { var score = 0; diff --git a/lib/ace/keyboard/emacs.js b/lib/ace/keyboard/emacs.js index 166c6857..7e855959 100644 --- a/lib/ace/keyboard/emacs.js +++ b/lib/ace/keyboard/emacs.js @@ -100,30 +100,30 @@ exports.handler.attach = function(editor) { editor.emacsMark = function() { return this.session.$emacsMark; - } + }; editor.setEmacsMark = function(p) { // to deactivate pass in a falsy value this.session.$emacsMark = p; - } + }; editor.pushEmacsMark = function(p, activate) { var prevMark = this.session.$emacsMark; if (prevMark) this.session.$emacsMarkRing.push(prevMark); - if (!p || activate) this.setEmacsMark(p) + if (!p || activate) this.setEmacsMark(p); else this.session.$emacsMarkRing.push(p); - } + }; editor.popEmacsMark = function() { var mark = this.emacsMark(); if (mark) { this.setEmacsMark(null); return mark; } return this.session.$emacsMarkRing.pop(); - } + }; editor.getLastEmacsMark = function(p) { return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0]; - } + }; editor.on("click", $resetMarkMode); editor.on("changeSession", $kbSessionChange); @@ -163,15 +163,15 @@ var $kbSessionChange = function(e) { e.session.$emacsMark = null; if (!e.session.hasOwnProperty('$emacsMarkRing')) e.session.$emacsMarkRing = []; -} +}; var $resetMarkMode = function(e) { e.editor.session.$emacsMark = null; -} +}; -var keys = require("../lib/keys").KEY_MODS, - eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"}, - combinations = ["C-S-M-CMD", +var keys = require("../lib/keys").KEY_MODS; +var eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"}; +var combinations = ["C-S-M-CMD", "S-M-CMD", "C-M-CMD", "C-S-CMD", "C-S-M", "M-CMD", "S-CMD", "S-M", "C-CMD", "C-M", "C-S", "CMD", "M", "S", "C"]; @@ -188,11 +188,11 @@ exports.handler.onCopy = function(e, editor) { editor.$handlesEmacsOnCopy = true; exports.handler.commands.killRingSave.exec(editor); delete editor.$handlesEmacsOnCopy; -} +}; exports.handler.onPaste = function(e, editor) { editor.pushEmacsMark(editor.getCursorPosition()); -} +}; exports.handler.bindKey = function(key, command) { if (!key) @@ -216,7 +216,7 @@ exports.handler.bindKey = function(key, command) { if (!ckb[keyPart]) ckb[keyPart] = "null"; }); }, this); -} +}; exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { var editor = data.editor; @@ -224,7 +224,7 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { if (hashId == -1) { editor.pushEmacsMark(); if (data.count) { - var str = Array(data.count + 1).join(key); + var str = new Array(data.count + 1).join(key); data.count = null; return {command: "insertstring", args: str}; } @@ -313,7 +313,7 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { } }; } else { - if (!args) args = {} + if (!args) args = {}; if (typeof args === 'object') args.count = count; } } @@ -508,8 +508,8 @@ exports.handler.addCommands({ killLine: function(editor) { editor.pushEmacsMark(null); var pos = editor.getCursorPosition(); - if (pos.column == 0 && - editor.session.doc.getLine(pos.row).length == 0) { + if (pos.column === 0 && + editor.session.doc.getLine(pos.row).length === 0) { // If an already empty line is killed, remove // the line entirely editor.selection.selectLine(); diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index 7af83b05..0a95ba3b 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -96,7 +96,7 @@ exports.handler = { if (util.currentMode === "insert") { this.onCompositionStartOrig(text); } - } + }; if (enable) { if (!editor.onCompositionUpdateOrig) { editor.onCompositionUpdateOrig = editor.onCompositionUpdate; @@ -134,7 +134,7 @@ exports.handler = { return {command: "null", passEvent: true}; } return {command: coreCommands.stop}; - } else if ((key == "esc" && hashId == 0) || key == "ctrl-[") { + } else if ((key == "esc" && hashId === 0) || key == "ctrl-[") { return {command: coreCommands.stop}; } else if (data.state == "start") { if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { @@ -142,15 +142,15 @@ exports.handler = { key = data.inputChar; } - if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) { + if (hashId == -1 || hashId == 1 || hashId === 0 && key.length > 1) { if (cmds.inputBuffer.idle && startCommands[key]) return startCommands[key]; cmds.inputBuffer.push(editor, key); return {command: "null", passEvent: false}; } // if no modifier || shift: wait for input. - else if (key.length == 1 && (hashId == 0 || hashId == 4)) { + else if (key.length == 1 && (hashId === 0 || hashId == 4)) { return {command: "null", passEvent: true}; - } else if (key == "esc" && hashId == 0) { + } else if (key == "esc" && hashId === 0) { return {command: coreCommands.stop}; } } else { diff --git a/lib/ace/lib/lang.js b/lib/ace/lib/lang.js index 4405b5c2..d6a98149 100644 --- a/lib/ace/lib/lang.js +++ b/lib/ace/lib/lang.js @@ -31,6 +31,10 @@ define(function(require, exports, module) { "use strict"; +exports.last = function(a) { + return a[a.length - 1]; +}; + exports.stringReverse = function(string) { return string.split("").reverse().join(""); }; diff --git a/lib/ace/mode/c9search_highlight_rules.js b/lib/ace/mode/c9search_highlight_rules.js index 3e9af29d..43ec4bf8 100644 --- a/lib/ace/mode/c9search_highlight_rules.js +++ b/lib/ace/mode/c9search_highlight_rules.js @@ -66,7 +66,7 @@ var C9SearchHighlightRules = function() { var m; var last = 0; - if (regex) { + if (regex && regex.exec) { regex.lastIndex = 0; while (m = regex.exec(str)) { var skipped = str.substring(last, m.index); @@ -92,42 +92,26 @@ var C9SearchHighlightRules = function() { regex : "Searching for .*$", onMatch: function(val, state, stack) { var parts = val.split("\x01"); - var search = parts[1]; if (parts.length < 3) return "text"; - var options = parts[2] == " in" ? parts[5] : parts[6]; - if (!/regex/.test(options)) - search = lang.escapeRegExp(search); - if (/whole/.test(options)) - search = "\\b" + search + "\\b"; - var regex = search && safeCreateRegexp( - "(" + search + ")", - / sensitive/.test(options) ? "g" : "ig" - ); - if (regex) { - stack[0] = state; - stack[1] = regex; - } + var options, search, replace; var i = 0; - var tokens = [ - { - value: parts[i++] + "'", - type: "text" - }, - { - value: parts[i++], - type: "text" // "c9searchresults.keyword" - }, - { - value: "'" + parts[i++], - type: "text" - } - ]; + var tokens = [{ + value: parts[i++] + "'", + type: "text" + }, { + value: search = parts[i++], + type: "text" // "c9searchresults.keyword" + }, { + value: "'" + parts[i++], + type: "text" + }]; // replaced if (parts[2] !== " in") { + replace = parts[i]; tokens.push({ value: "'" + parts[i++] + "'", type: "text" @@ -143,6 +127,7 @@ var C9SearchHighlightRules = function() { }); // options if (parts[i+1]) { + options = parts[i+1]; tokens.push({ value: "(" + parts[i+1] + ")", type: "text" @@ -151,11 +136,33 @@ var C9SearchHighlightRules = function() { } else { i -= 1; } - while (i++ < parts.length) + while (i++ < parts.length) { parts[i] && tokens.push({ value: parts[i], type: "text" }); + } + + if (replace) { + search = replace; + options = ""; + } + + if (search) { + if (!/regex/.test(options)) + search = lang.escapeRegExp(search); + if (/whole/.test(options)) + search = "\\b" + search + "\\b"; + } + + var regex = search && safeCreateRegexp( + "(" + search + ")", + / sensitive/.test(options) ? "g" : "ig" + ); + if (regex) { + stack[0] = state; + stack[1] = regex; + } return tokens; } diff --git a/lib/ace/mode/folding/c9search.js b/lib/ace/mode/folding/c9search.js index dd6a0b4f..a342d8a4 100644 --- a/lib/ace/mode/folding/c9search.js +++ b/lib/ace/mode/folding/c9search.js @@ -50,24 +50,30 @@ oop.inherits(FoldMode, BaseFoldMode); var level1 = /^(Found.*|Searching for.*)$/; var level2 = /^(\S.*\:|\s*)$/; var re = level1.test(line) ? level1 : level2; + + var startRow = row; + var endRow = row; if (this.foldingStartMarker.test(line)) { for (var i = row + 1, l = session.getLength(); i < l; i++) { if (re.test(lines[i])) break; } - - return new Range(row, line.length, i, 0); + endRow = i; } - - if (this.foldingStopMarker.test(line)) { + else if (this.foldingStopMarker.test(line)) { for (var i = row - 1; i >= 0; i--) { line = lines[i]; if (re.test(line)) break; } - - return new Range(i, line.length, row, 0); + startRow = i; + } + if (startRow != endRow) { + var col = line.length; + if (re === level1) + col = line.search(/\(Found[^)]+\)$|$/); + return new Range(startRow, col, endRow, 0); } }; diff --git a/lib/ace/mode/text.js b/lib/ace/mode/text.js index d04fed78..34a2a511 100644 --- a/lib/ace/mode/text.js +++ b/lib/ace/mode/text.js @@ -57,7 +57,7 @@ var Mode = function() { + unicode.packages.L + unicode.packages.Mn + unicode.packages.Mc + unicode.packages.Nd - + unicode.packages.Pc + "\\$_]|\s])+", "g" + + unicode.packages.Pc + "\\$_]|\\s])+", "g" ); this.getTokenizer = function() { @@ -217,10 +217,10 @@ var Mode = function() { var row = iterator.getCurrentTokenRow(); var column = iterator.getCurrentTokenColumn() + i; startRange = new Range(row, column, row, column + comment.start.length); - break + break; } token = iterator.stepBackward(); - }; + } var iterator = new TokenIterator(session, cursor.row, cursor.column); var token = iterator.getCurrentToken(); @@ -239,10 +239,10 @@ var Mode = function() { if (startRange) { session.remove(startRange); startRow = startRange.start.row; - colDiff = -comment.start.length + colDiff = -comment.start.length; } } else { - colDiff = comment.start.length + colDiff = comment.start.length; startRow = range.start.row; session.insert(range.end, comment.end); session.insert(range.start, comment.start); @@ -284,7 +284,8 @@ var Mode = function() { } } - var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions']; + var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent', + 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions']; for (var i = 0; i < delegations.length; i++) { (function(scope) { @@ -292,7 +293,7 @@ var Mode = function() { var defaultHandler = scope[functionName]; scope[delegations[i]] = function() { return this.$delegator(functionName, arguments, defaultHandler); - } + }; } (this)); } }; @@ -364,7 +365,7 @@ var Mode = function() { if (!this.$highlightRules) this.getTokenizer(); return this.$keywordList = this.$highlightRules.$keywordList || []; - } + }; this.getCompletions = function(state, session, pos, prefix) { var keywords = this.$keywordList || this.$createKeywordList(); diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 7e895f30..84e0ac48 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -238,7 +238,7 @@ function DefaultHandlers(mouseHandler) { if (ev.getAccelKey()) return; - //shift wheel to horiz scroll + //shift wheel to horiz scroll if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) { ev.wheelX = ev.wheelY; ev.wheelY = 0; diff --git a/lib/ace/worker/worker.js b/lib/ace/worker/worker.js index 04296156..b1b83ba9 100644 --- a/lib/ace/worker/worker.js +++ b/lib/ace/worker/worker.js @@ -17,7 +17,7 @@ window.window = window; window.ace = window; window.onerror = function(message, file, line, col, err) { - console.error("Worker " + err.stack); + console.error("Worker " + (err ? err.stack : message)); }; window.normalizeModule = function(parentId, moduleName) {