From 36f62e3792742248231ca5c4deaecb6f29456630 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 5 Sep 2014 23:53:16 +0400 Subject: [PATCH 1/7] fix #1840 The last CJK character of a wrapped line drops down --- lib/ace/edit_session.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index f563579d..1d5d63ae 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1958,6 +1958,8 @@ var EditSession = function(text, mode) { split = lastSplit + wrapLimit; // The split is inside of a CHAR or CHAR_EXT token and no space // around -> force a split. + if (tokens[split] == CHAR_EXT) + split--; addSplit(split); } return splits; From c0741f35118e4b1c382c1fee050756ddf5a023a2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 5 Sep 2014 23:55:16 +0400 Subject: [PATCH 2/7] fix #2119 Soft Hyphen (U+00AD) breaks cursor position calculation --- lib/ace/layer/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 7c3aa053..aeb74f1c 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -322,7 +322,7 @@ var Text = function(parentEl) { this.$renderToken = function(stringBuilder, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; + var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; var replaceFunc = function(c, a, b, tabIdx, idx4) { if (a) { return self.showInvisibles ? From bb76c62c7bc70a0f2cb66f5ff673b955454922c3 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 6 Sep 2014 02:23:37 +0400 Subject: [PATCH 3/7] fix several ie8 issues --- demo/kitchen-sink/styles.css | 8 +++++++- doc/site/js/main.js | 6 +++++- lib/ace/edit_session.js | 6 ++++-- lib/ace/keyboard/textinput.js | 11 ++++++++--- lib/ace/lib/keys.js | 4 +++- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/demo/kitchen-sink/styles.css b/demo/kitchen-sink/styles.css index 7db52e45..3f46f701 100644 --- a/demo/kitchen-sink/styles.css +++ b/demo/kitchen-sink/styles.css @@ -46,4 +46,10 @@ body { position: absolute; right: 0; border-left: 1px solid; -} \ No newline at end of file +} + +/* .ace_text-input { + z-index: 10!important; + opacity: 1!important; + background: rgb(84, 0, 255)!important; +}*/ diff --git a/doc/site/js/main.js b/doc/site/js/main.js index b24383c0..3b9eaa26 100644 --- a/doc/site/js/main.js +++ b/doc/site/js/main.js @@ -161,7 +161,11 @@ function highlight() { var highlighter = ace.require("ace/ext/static_highlight") var dom = ace.require("ace/lib/dom") function qsa(sel) { - return Array.apply(null, document.querySelectorAll(sel)); + var els = document.querySelectorAll(sel); + var result = []; + for (var i = 0, l = els.length; i < l; i++) + result[i] = els[i]; + return result; } qsa("code[class]").forEach(function(el) { diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 1d5d63ae..71cda95c 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -969,8 +969,10 @@ var EditSession = function(text, mode) { try { this.$worker = this.$mode.createWorker(this); } catch (e) { - console.log("Could not load worker"); - console.log(e); + if (typeof console == "object") { + console.log("Could not load worker"); + console.log(e); + } this.$worker = null; } }; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index e4e8f2a9..d2293024 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -51,6 +51,7 @@ var TextInput = function(parentNode, host) { text.spellcheck = false; text.style.opacity = "0"; + if (useragent.isOldIE) text.style.top = "-100px"; parentNode.insertBefore(text, parentNode.firstChild); var PLACEHOLDER = "\x01\x01"; @@ -436,6 +437,8 @@ var TextInput = function(parentNode, host) { }; this.moveToMouse = function(e, bringToFront) { + if (!bringToFront && useragent.isOldIE) + return; if (!tempStyle) tempStyle = text.style.cssText; text.style.cssText = (bringToFront ? "z-index:100000;" : "") @@ -460,13 +463,15 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = null; // on windows context menu is opened after mouseup - if (useragent.isWin) + if (useragent.isWin && !useragent.isOldIE) event.capture(host.container, move, onContextMenuClose); }; this.onContextMenuClose = onContextMenuClose; + var closeTimeout; function onContextMenuClose() { - setTimeout(function () { + clearTimeout(closeTimeout) + closeTimeout = setTimeout(function () { if (tempStyle) { text.style.cssText = tempStyle; tempStyle = ''; @@ -475,7 +480,7 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = true; host.renderer.$moveTextAreaToCursor(); } - }, 0); + }, useragent.isOldIE ? 200 : 0); } var onContextMenu = function(e) { diff --git a/lib/ace/lib/keys.js b/lib/ace/lib/keys.js index e708a5d4..e75a6e47 100644 --- a/lib/ace/lib/keys.js +++ b/lib/ace/lib/keys.js @@ -34,6 +34,8 @@ For more information about SproutCore, visit http://www.sproutcore.com define(function(require, exports, module) { "use strict"; +require("./fixoldbrowsers"); + var oop = require("./oop"); /* @@ -136,7 +138,7 @@ var Keys = (function() { (function() { var mods = ["cmd", "ctrl", "alt", "shift"]; - for (var i = Math.pow(2, mods.length); i--;) { + for (var i = Math.pow(2, mods.length); i--;) { ret.KEY_MODS[i] = mods.filter(function(x) { return i & ret.KEY_MODS[x]; }).join("-") + "-"; From e8f7419131f92ff80b951389aff4a3914423ec66 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 7 Sep 2014 14:46:20 +0400 Subject: [PATCH 4/7] fix #2054 Completer ignores better match if autoinsert is enabled --- lib/ace/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index 13d140d9..0d7f37ca 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -297,7 +297,7 @@ var Autocomplete = function() { return detachIfFinished(); // Autoinsert if one result - if (this.autoInsert && filtered.length == 1) + if (this.autoInsert && filtered.length == 1 && results.finished) return this.insertMatch(filtered[0]); this.openPopup(this.editor, prefix, keepPopupPosition); From 5f6782d949f293f2d6590b87f48f757afc642dc5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 7 Sep 2014 15:00:21 +0400 Subject: [PATCH 5/7] fix #2103 completion filtering doesn't work when started with empty prefix --- lib/ace/autocomplete.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index 0d7f37ca..be7c3aea 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -206,7 +206,8 @@ var Autocomplete = function() { var prefix = util.retrievePrecedingIdentifier(line, pos.column); this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); - + this.base.$insertRight = true; + var matches = []; var total = editor.completers.length; editor.completers.forEach(function(completer, i) { From e6660cd47c8cb8398b7775fd7408a2810aae69f9 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 7 Sep 2014 17:21:36 +0400 Subject: [PATCH 6/7] improve matlab highlighting fixes #2042, #2043 --- demo/kitchen-sink/docs/matlab.matlab | 18 +++++- lib/ace/mode/matlab_highlight_rules.js | 82 ++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 13 deletions(-) diff --git a/demo/kitchen-sink/docs/matlab.matlab b/demo/kitchen-sink/docs/matlab.matlab index 30404ce4..b2ca44d5 100644 --- a/demo/kitchen-sink/docs/matlab.matlab +++ b/demo/kitchen-sink/docs/matlab.matlab @@ -1 +1,17 @@ -TODO \ No newline at end of file +%{ + %{ + Ace Matlab demo + %} +%} + +classdef hello + methods + function greet(this) + disp('Hello!') % say hi + end + end +end + +% transpose +a = [ 'x''y', "x\n\ + y", 1' ]' + 2' \ No newline at end of file diff --git a/lib/ace/mode/matlab_highlight_rules.js b/lib/ace/mode/matlab_highlight_rules.js index 14474e2c..ee0e1ca8 100644 --- a/lib/ace/mode/matlab_highlight_rules.js +++ b/lib/ace/mode/matlab_highlight_rules.js @@ -164,15 +164,53 @@ var keywords = ( }, "identifier", true); this.$rules = { - "start" : [ { + // allowQstring + start: [{ + token : "string", + regex : "'", + stateName : "qstring", + next : [{ + token : "constant.language.escape", + regex : "''" + }, { + token : "string", + regex : "'|$", + next : "start" + }, { + defaultToken: "string" + }] + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", + next: "noQstring" + }], + noQstring : [{ + regex: "^\\s*%{\\s*$", + token: "comment.start", + push: "blockComment" + }, { token : "comment", regex : "%[^\r\n]*" }, { - token : "string", // " string - regex : '".*?"' - }, { - token : "string", // ' string - regex : "'.*?'" + token : "string", + regex : '"', + stateName : "qqstring", + next : [{ + token : "constant.language.escape", + regex : /\\./ + }, { + token : "string", + regex : "\\\\$", + next : "qqstring" + }, { + token : "string", + regex : '"|$', + next : "start" + }, { + defaultToken: "string" + }] }, { token : "constant.numeric", // float regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" @@ -181,21 +219,41 @@ var keywords = ( regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" + regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=", + next: "start" }, { - token : "punctuation.operator", - regex : "\\?|\\:|\\,|\\;|\\." + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\.", + next: "start" }, { token : "paren.lparen", - regex : "[\\(]" + regex : "[({\\[]", + next: "start" }, { token : "paren.rparen", - regex : "[\\)]" + regex : "[\\]})]" }, { token : "text", regex : "\\s+" - } ] + }, { + token : "text", + regex : "$", + next : "start" + }], + blockComment: [{ + regex: "^\\s*%{\\s*$", + token: "comment.start", + push: "blockComment" + }, { + regex: "^\\s*%}\\s*$", + token: "comment.end", + next: "pop" + }, { + defaultToken: "comment" + }], }; + + this.normalizeRules(); }; oop.inherits(MatlabHighlightRules, TextHighlightRules); From bd95f782d8fd5be28334e8783bba52406d95654c Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 7 Sep 2014 17:22:04 +0400 Subject: [PATCH 7/7] close completion popup when backspacing to empty string --- lib/ace/autocomplete.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index be7c3aea..1b54aa30 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -89,6 +89,8 @@ var Autocomplete = function() { pos.left += renderer.$gutterLayer.gutterWidth; this.popup.show(pos, lineHeight); + } else if (keepPopupPosition && !prefix) { + this.detach(); } };