vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.1.1 vs vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.1.2

- old
+ new

@@ -241,10 +241,11 @@ var indentString = line.match(/^\s*/)[0]; if (cursor.column < indentString.length) indentString = indentString.slice(0, cursor.column); + snippetText = snippetText.replace(/\r/g, ""); var tokens = this.tokenizeTmSnippet(snippetText); tokens = this.resolveVariables(tokens, editor); tokens = tokens.map(function(x) { if (x == "\n") return x + indentString; @@ -318,13 +319,14 @@ } var row = 0, column = 0; var text = ""; tokens.forEach(function(t) { if (typeof t === "string") { - if (t[0] === "\n"){ - column = t.length - 1; - row ++; + var lines = t.split("\n"); + if (lines.length > 1){ + column = lines[lines.length - 1].length; + row += lines.length - 1; } else column += t.length; text += t; } else { if (!t.start) @@ -1131,16 +1133,19 @@ var screenHeight = window.innerHeight; var screenWidth = window.innerWidth; var renderer = this.renderer; var maxH = renderer.$maxLines * lineHeight * 1.4; var top = pos.top + this.$borderSize; - if (top + maxH > screenHeight - lineHeight && !topdownOnly) { + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; el.style.top = ""; el.style.bottom = screenHeight - top + "px"; popup.isTopdown = false; } else { top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; el.style.top = top + "px"; el.style.bottom = ""; popup.isTopdown = true; } @@ -1383,9 +1388,12 @@ else this.detach(); }; this.blurListener = function(e) { + if (e.relatedTarget && e.relatedTarget.nodeName == "A" && e.relatedTarget.href) { + window.open(e.relatedTarget.href, "_blank"); + } var el = document.activeElement; var text = this.editor.textInput.getElement(); var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode; var container = this.popup && this.popup.container; if (el != text && el.parentNode != container && !fromTooltip \ No newline at end of file