summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon')
-rw-r--r--public/vendor/codemirror/addon/comment/comment.js11
-rw-r--r--public/vendor/codemirror/addon/dialog/dialog.js4
-rw-r--r--public/vendor/codemirror/addon/display/placeholder.js2
-rw-r--r--public/vendor/codemirror/addon/hint/show-hint.js11
-rw-r--r--public/vendor/codemirror/addon/hint/sql-hint.js59
-rw-r--r--public/vendor/codemirror/addon/lint/lint.js15
-rw-r--r--public/vendor/codemirror/addon/merge/merge.css1
-rw-r--r--public/vendor/codemirror/addon/merge/merge.js5
-rw-r--r--public/vendor/codemirror/addon/scroll/simplescrollbars.js18
-rw-r--r--public/vendor/codemirror/addon/search/match-highlighter.js2
-rw-r--r--public/vendor/codemirror/addon/search/search.js7
-rw-r--r--public/vendor/codemirror/addon/selection/active-line.js3
-rw-r--r--public/vendor/codemirror/addon/tern/tern.js4
13 files changed, 101 insertions, 41 deletions
diff --git a/public/vendor/codemirror/addon/comment/comment.js b/public/vendor/codemirror/addon/comment/comment.js
index 3aa46808..2c4f975d 100644
--- a/public/vendor/codemirror/addon/comment/comment.js
+++ b/public/vendor/codemirror/addon/comment/comment.js
@@ -44,9 +44,17 @@
}
});
+ // Rough heuristic to try and detect lines that are part of multi-line string
+ function probablyInsideString(cm, pos, line) {
+ return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
+ }
+
CodeMirror.defineExtension("lineComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = self.getModeAt(from);
+ var firstLine = self.getLine(from.line);
+ if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
+
var commentString = options.lineComment || mode.lineComment;
if (!commentString) {
if (options.blockCommentStart || mode.blockCommentStart) {
@@ -55,8 +63,7 @@
}
return;
}
- var firstLine = self.getLine(from.line);
- if (firstLine == null) return;
+
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
var pad = options.padding == null ? " " : options.padding;
var blankLines = options.commentBlankLines || from.line == to.line;
diff --git a/public/vendor/codemirror/addon/dialog/dialog.js b/public/vendor/codemirror/addon/dialog/dialog.js
index 323b2007..f10bb5bf 100644
--- a/public/vendor/codemirror/addon/dialog/dialog.js
+++ b/public/vendor/codemirror/addon/dialog/dialog.js
@@ -56,6 +56,8 @@
var inp = dialog.getElementsByTagName("input")[0], button;
if (inp) {
+ inp.focus();
+
if (options.value) {
inp.value = options.value;
if (options.selectValueOnOpen !== false) {
@@ -79,8 +81,6 @@
});
if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
-
- inp.focus();
} else if (button = dialog.getElementsByTagName("button")[0]) {
CodeMirror.on(button, "click", function() {
close();
diff --git a/public/vendor/codemirror/addon/display/placeholder.js b/public/vendor/codemirror/addon/display/placeholder.js
index babddfb1..2f8b1f84 100644
--- a/public/vendor/codemirror/addon/display/placeholder.js
+++ b/public/vendor/codemirror/addon/display/placeholder.js
@@ -14,10 +14,12 @@
if (val && !prev) {
cm.on("blur", onBlur);
cm.on("change", onChange);
+ cm.on("swapDoc", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
cm.off("change", onChange);
+ cm.off("swapDoc", onChange);
clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
diff --git a/public/vendor/codemirror/addon/hint/show-hint.js b/public/vendor/codemirror/addon/hint/show-hint.js
index cbe3b39a..7661f6c2 100644
--- a/public/vendor/codemirror/addon/hint/show-hint.js
+++ b/public/vendor/codemirror/addon/hint/show-hint.js
@@ -121,11 +121,13 @@
finishUpdate: function(data, first) {
if (this.data) CodeMirror.signal(this.data, "update");
- if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
- this.data = data;
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
if (this.widget) this.widget.close();
+
+ if (data && this.data && isNewCompletion(this.data, data)) return;
+ this.data = data;
+
if (data && data.list.length) {
if (picked && data.list.length == 1) {
this.pick(data, 0);
@@ -137,6 +139,11 @@
}
};
+ function isNewCompletion(old, nw) {
+ var moved = CodeMirror.cmpPos(nw.from, old.from)
+ return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
+ }
+
function parseOptions(cm, pos, options) {
var editor = cm.options.hintOptions;
var out = {};
diff --git a/public/vendor/codemirror/addon/hint/sql-hint.js b/public/vendor/codemirror/addon/hint/sql-hint.js
index 22124b58..62c4f68d 100644
--- a/public/vendor/codemirror/addon/hint/sql-hint.js
+++ b/public/vendor/codemirror/addon/hint/sql-hint.js
@@ -20,6 +20,8 @@
};
var Pos = CodeMirror.Pos;
+ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
+
function getKeywords(editor) {
var mode = editor.doc.modeOption;
if (mode === "sql") mode = "text/x-sql";
@@ -30,10 +32,28 @@
return typeof item == "string" ? item : item.text;
}
- function getItem(list, item) {
- if (!list.slice) return list[item];
- for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
- return list[i];
+ function wrapTable(name, value) {
+ if (isArray(value)) value = {columns: value}
+ if (!value.text) value.text = name
+ return value
+ }
+
+ function parseTables(input) {
+ var result = {}
+ if (isArray(input)) {
+ for (var i = input.length - 1; i >= 0; i--) {
+ var item = input[i]
+ result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
+ }
+ } else if (input) {
+ for (var name in input)
+ result[name.toUpperCase()] = wrapTable(name, input[name])
+ }
+ return result
+ }
+
+ function getTable(name) {
+ return tables[name.toUpperCase()]
}
function shallowClone(object) {
@@ -50,11 +70,18 @@
}
function addMatches(result, search, wordlist, formatter) {
- for (var word in wordlist) {
- if (!wordlist.hasOwnProperty(word)) continue;
- if (wordlist.slice) word = wordlist[word];
-
- if (match(search, word)) result.push(formatter(word));
+ if (isArray(wordlist)) {
+ for (var i = 0; i < wordlist.length; i++)
+ if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
+ } else {
+ for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
+ var val = wordlist[word]
+ if (!val || val === true)
+ val = word
+ else
+ val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
+ if (match(search, val)) result.push(formatter(val))
+ }
}
}
@@ -78,7 +105,7 @@
}
function nameCompletion(cur, token, result, editor) {
- // Try to complete table, colunm names and return start position of completion
+ // Try to complete table, column names and return start position of completion
var useBacktick = false;
var nameParts = [];
var start = token.start;
@@ -115,13 +142,13 @@
var alias = false;
var aliasTable = table;
// Check if table is available. If not, find table by Alias
- if (!getItem(tables, table)) {
+ if (!getTable(table)) {
var oldTable = table;
table = findTableByAlias(table, editor);
if (table !== oldTable) alias = true;
}
- var columns = getItem(tables, table);
+ var columns = getTable(table);
if (columns && columns.columns)
columns = columns.columns;
@@ -184,7 +211,7 @@
//find valid range
var prevItem = 0;
var current = convertCurToNumber(editor.getCursor());
- for (var i=0; i< separator.length; i++) {
+ for (var i = 0; i < separator.length; i++) {
var _v = convertCurToNumber(separator[i]);
if (current > prevItem && current <= _v) {
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
@@ -199,7 +226,7 @@
var lineText = query[i];
eachWord(lineText, function(word) {
var wordUpperCase = word.toUpperCase();
- if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
+ if (wordUpperCase === aliasUpperCase && getTable(previousWord))
table = previousWord;
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
previousWord = word;
@@ -210,10 +237,10 @@
}
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
- tables = (options && options.tables) || {};
+ tables = parseTables(options && options.tables)
var defaultTableName = options && options.defaultTable;
var disableKeywords = options && options.disableKeywords;
- defaultTable = defaultTableName && getItem(tables, defaultTableName);
+ defaultTable = defaultTableName && getTable(defaultTableName);
keywords = keywords || getKeywords(editor);
if (defaultTableName && !defaultTable)
diff --git a/public/vendor/codemirror/addon/lint/lint.js b/public/vendor/codemirror/addon/lint/lint.js
index 5afe49d0..01f322b5 100644
--- a/public/vendor/codemirror/addon/lint/lint.js
+++ b/public/vendor/codemirror/addon/lint/lint.js
@@ -186,9 +186,14 @@
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
}
- function popupSpanTooltip(ann, e) {
+ function popupTooltips(annotations, e) {
var target = e.target || e.srcElement;
- showTooltipFor(e, annotationTooltip(ann), target);
+ var tooltip = document.createDocumentFragment();
+ for (var i = 0; i < annotations.length; i++) {
+ var ann = annotations[i];
+ tooltip.appendChild(annotationTooltip(ann));
+ }
+ showTooltipFor(e, tooltip, target);
}
function onMouseOver(cm, e) {
@@ -196,10 +201,12 @@
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
+
+ var annotations = [];
for (var i = 0; i < spans.length; ++i) {
- var ann = spans[i].__annotation;
- if (ann) return popupSpanTooltip(ann, e);
+ annotations.push(spans[i].__annotation);
}
+ if (annotations.length) popupTooltips(annotations, e);
}
CodeMirror.defineOption("lint", false, function(cm, val, old) {
diff --git a/public/vendor/codemirror/addon/merge/merge.css b/public/vendor/codemirror/addon/merge/merge.css
index a6a80e43..bda3d9f8 100644
--- a/public/vendor/codemirror/addon/merge/merge.css
+++ b/public/vendor/codemirror/addon/merge/merge.css
@@ -60,6 +60,7 @@
position: absolute;
cursor: pointer;
color: #44c;
+ z-index: 3;
}
.CodeMirror-merge-copy-reverse {
diff --git a/public/vendor/codemirror/addon/merge/merge.js b/public/vendor/codemirror/addon/merge/merge.js
index 830a5f02..d67b760c 100644
--- a/public/vendor/codemirror/addon/merge/merge.js
+++ b/public/vendor/codemirror/addon/merge/merge.js
@@ -427,8 +427,9 @@
function copyChunk(dv, to, from, chunk) {
if (dv.diffOutOfDate) return;
- to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
- Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
+ var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
+ var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
+ to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
}
// Merge view, containing 0, 1, or 2 diff views.
diff --git a/public/vendor/codemirror/addon/scroll/simplescrollbars.js b/public/vendor/codemirror/addon/scroll/simplescrollbars.js
index f78353a1..32ba2f35 100644
--- a/public/vendor/codemirror/addon/scroll/simplescrollbars.js
+++ b/public/vendor/codemirror/addon/scroll/simplescrollbars.js
@@ -59,16 +59,20 @@
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
}
- Bar.prototype.moveTo = function(pos, update) {
+ Bar.prototype.setPos = function(pos) {
if (pos < 0) pos = 0;
if (pos > this.total - this.screen) pos = this.total - this.screen;
- if (pos == this.pos) return;
+ if (pos == this.pos) return false;
this.pos = pos;
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
(pos * (this.size / this.total)) + "px";
- if (update !== false) this.scroll(pos, this.orientation);
+ return true
};
+ Bar.prototype.moveTo = function(pos) {
+ if (this.setPos(pos)) this.scroll(pos, this.orientation);
+ }
+
var minButtonSize = 10;
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
@@ -83,8 +87,7 @@
}
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
buttonSize + "px";
- this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
- this.pos * (this.size / this.total) + "px";
+ this.setPos(this.pos);
};
function SimpleScrollbars(cls, place, scroll) {
@@ -111,7 +114,6 @@
if (needsV) {
this.vert.update(measure.scrollHeight, measure.clientHeight,
measure.viewHeight - (needsH ? width : 0));
- this.vert.node.style.display = "block";
this.vert.node.style.bottom = needsH ? width + "px" : "0";
}
if (needsH) {
@@ -125,11 +127,11 @@
};
SimpleScrollbars.prototype.setScrollTop = function(pos) {
- this.vert.moveTo(pos, false);
+ this.vert.setPos(pos);
};
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
- this.horiz.moveTo(pos, false);
+ this.horiz.setPos(pos);
};
SimpleScrollbars.prototype.clear = function() {
diff --git a/public/vendor/codemirror/addon/search/match-highlighter.js b/public/vendor/codemirror/addon/search/match-highlighter.js
index 8f02f01c..79218c31 100644
--- a/public/vendor/codemirror/addon/search/match-highlighter.js
+++ b/public/vendor/codemirror/addon/search/match-highlighter.js
@@ -16,7 +16,7 @@
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
-// highlighting the matches. If annotateScrollbar is enabled, the occurances
+// highlighting the matches. If annotateScrollbar is enabled, the occurences
// will be highlighted on the scrollbar via the matchesonscrollbar addon.
(function(mod) {
diff --git a/public/vendor/codemirror/addon/search/search.js b/public/vendor/codemirror/addon/search/search.js
index 93e90b36..e6b4f85a 100644
--- a/public/vendor/codemirror/addon/search/search.js
+++ b/public/vendor/codemirror/addon/search/search.js
@@ -121,7 +121,10 @@
persistentDialog(cm, queryDialog, q, function(query, event) {
CodeMirror.e_stop(event);
if (!query) return;
- if (query != state.queryText) startSearch(cm, state, query);
+ if (query != state.queryText) {
+ startSearch(cm, state, query);
+ state.posFrom = state.posTo = cm.getCursor();
+ }
if (hiding) hiding.style.opacity = 1
findNext(cm, event.shiftKey, function(_, to) {
var dialog
@@ -193,7 +196,7 @@
replaceAll(cm, query, text)
} else {
clearSearch(cm);
- var cursor = getSearchCursor(cm, query, cm.getCursor());
+ var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
var advance = function() {
var start = cursor.from(), match;
if (!(match = cursor.findNext())) {
diff --git a/public/vendor/codemirror/addon/selection/active-line.js b/public/vendor/codemirror/addon/selection/active-line.js
index 22da2e0a..b0b3f61a 100644
--- a/public/vendor/codemirror/addon/selection/active-line.js
+++ b/public/vendor/codemirror/addon/selection/active-line.js
@@ -18,6 +18,7 @@
"use strict";
var WRAP_CLASS = "CodeMirror-activeline";
var BACK_CLASS = "CodeMirror-activeline-background";
+ var GUTT_CLASS = "CodeMirror-activeline-gutter";
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
@@ -36,6 +37,7 @@
for (var i = 0; i < cm.state.activeLines.length; i++) {
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
+ cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
}
}
@@ -60,6 +62,7 @@
for (var i = 0; i < active.length; i++) {
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
cm.addLineClass(active[i], "background", BACK_CLASS);
+ cm.addLineClass(active[i], "gutter", GUTT_CLASS);
}
cm.state.activeLines = active;
});
diff --git a/public/vendor/codemirror/addon/tern/tern.js b/public/vendor/codemirror/addon/tern/tern.js
index c345c497..efdf2ed6 100644
--- a/public/vendor/codemirror/addon/tern/tern.js
+++ b/public/vendor/codemirror/addon/tern/tern.js
@@ -179,7 +179,7 @@
var data = findDoc(ts, doc);
var argHints = ts.cachedArgHints;
- if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
+ if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0)
ts.cachedArgHints = null;
var changed = data.changed;
@@ -306,7 +306,7 @@
ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
if (error || !data.type || !(/^fn\(/).test(data.type)) return;
ts.cachedArgHints = {
- start: pos,
+ start: start,
type: parseFnType(data.type),
name: data.exprName || data.name || "fn",
guess: data.guess,