diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 634125f6..d565bd81 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -88,8 +88,6 @@ split.on("focus", function(editor) { }); env.split = split; window.env = env; -window.ace = env.editor; -env.editor.setAnimatedScroll(true); // add multiple cursor support to editor require("ace/multi_select").MultiSelect(env.editor); @@ -617,3 +615,13 @@ env.editor.setOptions({ }) }); + +// allow easy access to ace in console, but not in ace code which uses strict +function isNonStrict() { + try { return !!arguments.callee.caller.caller } + catch(e){ return false } +} +window.__defineGetter__("ace", function(){ return isNonStrict() && env.editor }); +window.__defineGetter__("editor", function(){ return isNonStrict() && env.editor }); +window.__defineGetter__("session", function(){ return isNonStrict() && env.editor.session }); +window.__defineGetter__("split", function(){ return isNonStrict() && env.split }); diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index e1ec86c2..4cf29073 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -206,9 +206,12 @@ var AcePopup = function(parentNode) { }; popup.show = function(pos, lineHeight) { var el = this.container; - if (pos.top > window.innerHeight / 2 + lineHeight) { + var screenHeight = window.innerHeight; + var renderer = this.renderer; + var maxH = renderer.$maxLines * lineHeight; + if (pos.top +maxH > screenHeight - lineHeight) { el.style.top = ""; - el.style.bottom = window.innerHeight - pos.top + "px"; + el.style.bottom = screenHeight - pos.top + "px"; } else { pos.top += lineHeight; el.style.top = pos.top + "px"; diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 9f31841c..41e0fa15 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -885,9 +885,11 @@ var EditSession = function(text, mode) { if (!this.$modes["ace/mode/text"]) this.$modes["ace/mode/text"] = new TextMode(); - if (this.$modes[path] && !options) - return this.$onChangeMode(this.$modes[path]); - + if (this.$modes[path] && !options) { + this.$onChangeMode(this.$modes[path]); + cb && cb(); + return; + } // load on demand this.$modeId = path; config.loadModule(["mode", path], function(m) { @@ -902,7 +904,7 @@ var EditSession = function(text, mode) { m.$id = path; } this.$onChangeMode(m); - cb && cb(this.mode); + cb && cb(); } }.bind(this)); diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index fc7bfb67..48e016b0 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -212,6 +212,11 @@ var TextHighlightRules = function() { for (var i = list.length; i--; ) keywords[list[i]] = className; }); + // in old versions of opera keywords["__proto__"] sets prototype + // even on objects with __proto__=null + if (Object.getPrototypeOf(keywords)) { + keywords.__proto__ = null; + } this.$keywordList = Object.keys(keywords); map = null; return ignoreCase diff --git a/lib/ace/snippets.js b/lib/ace/snippets.js index aa1d71b5..6d7e22b5 100644 --- a/lib/ace/snippets.js +++ b/lib/ace/snippets.js @@ -155,11 +155,13 @@ var SnippetManager = function() { case "SELECTED_TEXT": return s.getTextRange(r); case "CURRENT_LINE": - return s.getLine(e.getCursorPosition().row); + return s.getLine(editor.getCursorPosition().row); + case "PREV_LINE": // not possible in textmate + return s.getLine(editor.getCursorPosition().row - 1); case "LINE_INDEX": - return e.getCursorPosition().column; + return editor.getCursorPosition().column; case "LINE_NUMBER": - return e.getCursorPosition().row + 1; + return editor.getCursorPosition().row + 1; case "SOFT_TABS": return s.getUseSoftTabs() ? "YES" : "NO"; case "TAB_SIZE": diff --git a/lib/ace/snippets/markdown.snippets b/lib/ace/snippets/markdown.snippets index e4efd3c2..a5110fc9 100644 --- a/lib/ace/snippets/markdown.snippets +++ b/lib/ace/snippets/markdown.snippets @@ -23,14 +23,15 @@ snippet ![:* ![${1:id}]: ${2:`@*`} "${3:title}" snippet === - `repeat('=', strlen(getline(line(".") - 1)))` +regex /^/=+/=*// + ${PREV_LINE/./=/g} - ${1} + ${0} snippet --- - `repeat('-', strlen(getline(line(".") - 1)))` +regex /^/-+/-*// + ${PREV_LINE/./-/g} - ${1} - + ${0} snippet blockquote {% blockquote %} ${1:quote} diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index b4ef627b..6d63b075 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -34,8 +34,6 @@ define(function(require, exports, module) { // tokenizing lines longer than this makes editor very slow var MAX_TOKEN_COUNT = 1000; /** - * - * * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter). * @class Tokenizer **/ @@ -128,6 +126,10 @@ var Tokenizer = function(rules) { }; (function() { + this.$setMaxTokenCount = function(m) { + MAX_TOKEN_COUNT = m | 0; + }; + this.$applyToken = function(str) { var values = this.splitRegex.exec(str).slice(1); var types = this.token.apply(this, values);