From a842dcdee349905c8c83830c1ec5716bbe8640b8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 26 Apr 2015 14:38:49 +0400 Subject: [PATCH 1/8] do not retain ref to the first editor (fixes #2469) --- experiments/debug_mem_leak.html | 59 +++++++++++++++++++++++++++++++++ lib/ace/lib/event.js | 9 ++--- 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 experiments/debug_mem_leak.html diff --git a/experiments/debug_mem_leak.html b/experiments/debug_mem_leak.html new file mode 100644 index 00000000..b8ee8726 --- /dev/null +++ b/experiments/debug_mem_leak.html @@ -0,0 +1,59 @@ + + + + + + + + +

+ +
+ + + \ No newline at end of file diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js index 16805ce2..57924056 100644 --- a/lib/ace/lib/event.js +++ b/lib/ace/lib/event.js @@ -326,13 +326,14 @@ exports.addCommandKeyListener = function(el, callback) { }); if (!pressedKeys) { - pressedKeys = Object.create(null); - addListener(window, "focus", function(e) { - pressedKeys = Object.create(null); - }); + resetPressedKeys(); + addListener(window, "focus", resetPressedKeys); } } }; +function resetPressedKeys(e) { + pressedKeys = Object.create(null); +} if (window.postMessage && !useragent.isOldIE) { var postMessageId = 1; From d080fe51d4433c9217bc40acbbc5876843254e7a Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 28 Apr 2015 19:01:24 +0400 Subject: [PATCH 2/8] fix #2468 error in strict mode --- lib/ace/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/config.js b/lib/ace/config.js index 34bf50fd..fe9312fd 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -39,7 +39,7 @@ var AppConfig = require("./lib/app_config").AppConfig; module.exports = exports = new AppConfig(); var global = (function() { - return this; + return this || typeof window != "undefined" && window; })(); var options = { From e72f1d833751756fdb237a35ff0a9549487bf0bf Mon Sep 17 00:00:00 2001 From: Alex Gilding Date: Tue, 28 Apr 2015 20:24:13 +0100 Subject: [PATCH 3/8] Add indentation for Scheme Just copied over the Clojure indentation rules to Scheme and changed the keywords to suit the language, so that Scheme programs can be automatically indented too --- lib/ace/mode/scheme.js | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/lib/ace/mode/scheme.js b/lib/ace/mode/scheme.js index aa462a10..2360b3da 100644 --- a/lib/ace/mode/scheme.js +++ b/lib/ace/mode/scheme.js @@ -39,15 +39,92 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SchemeHighlightRules = require("./scheme_highlight_rules").SchemeHighlightRules; +var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent; var Mode = function() { this.HighlightRules = SchemeHighlightRules; + this.$outdent = new MatchingParensOutdent(); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = ";"; + this.minorIndentFunctions = ["define", "lambda", "define-macro", "define-syntax", "syntax-rules", "define-record-type", "define-structure"]; + + this.$toIndent = function(str) { + return str.split('').map(function(ch) { + if (/\s/.exec(ch)) { + return ch; + } else { + return ' '; + } + }).join(''); + }; + + this.$calculateIndent = function(line, tab) { + var baseIndent = this.$getIndent(line); + var delta = 0; + var isParen, ch; + // Walk back from end of line, find matching braces + for (var i = line.length - 1; i >= 0; i--) { + ch = line[i]; + if (ch === '(') { + delta--; + isParen = true; + } else if (ch === '(' || ch === '[' || ch === '{') { + delta--; + isParen = false; + } else if (ch === ')' || ch === ']' || ch === '}') { + delta++; + } + if (delta < 0) { + break; + } + } + if (delta < 0 && isParen) { + // Were more brackets opened than closed and was a ( left open? + i += 1; + var iBefore = i; + var fn = ''; + while (true) { + ch = line[i]; + if (ch === ' ' || ch === '\t') { + if(this.minorIndentFunctions.indexOf(fn) !== -1) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } else { + return this.$toIndent(line.substring(0, i + 1)); + } + } else if (ch === undefined) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } + fn += line[i]; + i++; + } + } else if(delta < 0 && !isParen) { + // Were more brackets openend than closed and was it not a (? + return this.$toIndent(line.substring(0, i+1)); + } else if(delta > 0) { + // Mere more brackets closed than opened? Outdent. + baseIndent = baseIndent.substring(0, baseIndent.length - tab.length); + return baseIndent; + } else { + // Were they nicely matched? Just indent like line before. + return baseIndent; + } + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$calculateIndent(line, tab); + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; this.$id = "ace/mode/scheme"; }).call(Mode.prototype); From a61d304cbb348432fa3c71099ffa3809ccabd3ee Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Thu, 30 Apr 2015 17:14:16 -0700 Subject: [PATCH 4/8] Remove unused variable `EditSession` --- lib/ace/autocomplete/popup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index a151c746..ead0c47c 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -31,7 +31,6 @@ define(function(require, exports, module) { "use strict"; -var EditSession = require("../edit_session").EditSession; var Renderer = require("../virtual_renderer").VirtualRenderer; var Editor = require("../editor").Editor; var Range = require("../range").Range; From cd8099b0ad952c916f512b2309d82920da388103 Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Thu, 30 Apr 2015 17:38:19 -0700 Subject: [PATCH 5/8] Remove unused parameter `mutateData` & add ;s --- lib/ace/autocomplete.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index 7e5674ae..d3b41b65 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -142,7 +142,7 @@ var Autocomplete = function() { // we have to check if activeElement is a child of popup because // on IE preventDefault doesn't stop scrollbar from being focussed var el = document.activeElement; - var text = this.editor.textInput.getElement() + var text = this.editor.textInput.getElement(); if (el != text && ( !this.popup || el.parentNode != this.popup.container ) && el != this.tooltipNode && e.relatedTarget != this.tooltipNode && e.relatedTarget != text @@ -349,7 +349,7 @@ var Autocomplete = function() { doc = selected; if (typeof doc == "string") - doc = {docText: doc} + doc = {docText: doc}; if (!doc || !(doc.docHTML || doc.docText)) return this.hideDocTooltip(); this.showDocTooltip(doc); @@ -416,7 +416,7 @@ Autocomplete.startCommand = { bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" }; -var FilteredList = function(array, filterText, mutateData) { +var FilteredList = function(array, filterText) { this.all = array; this.filtered = array; this.filterText = filterText || ""; From ad22b71cfe9293dda3fe1c689299d08580f29441 Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Fri, 1 May 2015 10:56:08 -0700 Subject: [PATCH 6/8] Update comment, add missing semicolon [ci skip] --- lib/ace/edit_session.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 3e941375..7296dc34 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -151,7 +151,7 @@ var EditSession = function(text, mode) { this.$foldData = []; this.$foldData.toString = function() { return this.join("\n"); - } + }; this.on("changeFold", this.onChangeFold.bind(this)); this.$onChange = this.onChange.bind(this); @@ -679,10 +679,10 @@ var EditSession = function(text, mode) { }; /** - * Returns an array containing the IDs of all the markers, either front or back. + * Returns an object containing the all of the markers, either front or back. * @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers * - * @returns {Array} + * @returns {Object} **/ this.getMarkers = function(inFront) { return inFront ? this.$frontMarkers : this.$backMarkers; From ef4537a09981f142b11a79b47c6e242e04bd2a80 Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Tue, 5 May 2015 09:07:46 -0700 Subject: [PATCH 7/8] Update edit_session.js Fix extra `the` --- lib/ace/edit_session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 7296dc34..f9b43a76 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -679,7 +679,7 @@ var EditSession = function(text, mode) { }; /** - * Returns an object containing the all of the markers, either front or back. + * Returns an object containing all of the markers, either front or back. * @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers * * @returns {Object} From 0abd9ec30e4bc6225cb01b62e34cc5ba1fd23b1f Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 11 Oct 2014 02:38:06 +0400 Subject: [PATCH 8/8] rounded corners for selections --- lib/ace/css/editor.css | 27 ++++++++++++ lib/ace/layer/marker.js | 51 ++++++++++++----------- lib/ace/theme/clouds.css | 1 - lib/ace/theme/clouds_midnight.css | 1 - lib/ace/theme/cobalt.css | 1 - lib/ace/theme/dawn.css | 1 - lib/ace/theme/idle_fingers.css | 1 - lib/ace/theme/katzenmilch.css | 1 - lib/ace/theme/kr_theme.css | 1 - lib/ace/theme/merbivore.css | 1 - lib/ace/theme/merbivore_soft.css | 1 - lib/ace/theme/mono_industrial.css | 1 - lib/ace/theme/monokai.css | 1 - lib/ace/theme/pastel_on_dark.css | 1 - lib/ace/theme/solarized_dark.css | 1 - lib/ace/theme/solarized_light.css | 1 - lib/ace/theme/terminal.css | 1 - lib/ace/theme/textmate.css | 1 - lib/ace/theme/tomorrow.css | 1 - lib/ace/theme/tomorrow_night.css | 1 - lib/ace/theme/tomorrow_night_blue.css | 1 - lib/ace/theme/tomorrow_night_bright.css | 1 - lib/ace/theme/tomorrow_night_eighties.css | 1 - lib/ace/theme/twilight.css | 1 - lib/ace/theme/vibrant_ink.css | 1 - lib/ace/theme/xcode.css | 1 - 26 files changed, 54 insertions(+), 48 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index cef995c8..87eb67b3 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -422,3 +422,30 @@ position: absolute; z-index: 8; } + +/* +styles = [] +for (var i = 1; i < 16; i++) { + styles.push(".ace_br" + i + "{" + ( + ["top-left", "top-right", "bottom-right", "bottom-left"] + ).map(function(x, j) { + return i & (1< next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; @@ -136,7 +137,7 @@ var Marker = function(parentEl) { extraStyle = extraStyle || ""; stringBuilder.push( - "