codemirror-rails 4.12 → 4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +45 -22
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +6 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +1 -1
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +14 -9
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +94 -51
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +2 -1
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +211 -123
- data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +36 -12
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/selection/selection-pointer.js +3 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +31 -4
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +46 -7
- data/vendor/assets/javascripts/codemirror/modes/clike.js +5 -1
- data/vendor/assets/javascripts/codemirror/modes/css.js +104 -55
- data/vendor/assets/javascripts/codemirror/modes/cypher.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/forth.js +180 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/idl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/stylus.js +444 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +192 -19
- data/vendor/assets/stylesheets/codemirror/themes/colorforth.css +33 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 893503095237028fea620f11e8cc5a6eca7873b5
|
4
|
+
data.tar.gz: 97b7ef4412832ae76014e97a63b6b213b00e57be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43a90310c194f85795aeede4d02fbfab6a34b3ae68523925fa3073ea1479cbabf1d87610abb4cb475dc327f18fd03c407142907167a02950772e9a2548829e0b
|
7
|
+
data.tar.gz: 2ffd75777cb370c1fbd861214816b89cb06b9b00e6e1833058b667dc0dfa14df482c212926e90e85867f3f9032897ad5130ee2c97758de8b5af0f3a888500353
|
@@ -110,6 +110,7 @@
|
|
110
110
|
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
111
111
|
optionHandlers[opt](this, options[opt], Init);
|
112
112
|
maybeUpdateLineNumberWidth(this);
|
113
|
+
if (options.finishInit) options.finishInit(this);
|
113
114
|
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
|
114
115
|
endOperation(this);
|
115
116
|
// Suppress optimizelegibility in Webkit, since it breaks text
|
@@ -649,8 +650,18 @@
|
|
649
650
|
this.oldDisplayWidth = displayWidth(cm);
|
650
651
|
this.force = force;
|
651
652
|
this.dims = getDimensions(cm);
|
653
|
+
this.events = [];
|
652
654
|
}
|
653
655
|
|
656
|
+
DisplayUpdate.prototype.signal = function(emitter, type) {
|
657
|
+
if (hasHandler(emitter, type))
|
658
|
+
this.events.push(arguments);
|
659
|
+
};
|
660
|
+
DisplayUpdate.prototype.finish = function() {
|
661
|
+
for (var i = 0; i < this.events.length; i++)
|
662
|
+
signal.apply(null, this.events[i]);
|
663
|
+
};
|
664
|
+
|
654
665
|
function maybeClipScrollbars(cm) {
|
655
666
|
var display = cm.display;
|
656
667
|
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
@@ -761,9 +772,9 @@
|
|
761
772
|
updateScrollbars(cm, barMeasure);
|
762
773
|
}
|
763
774
|
|
764
|
-
|
775
|
+
update.signal(cm, "update", cm);
|
765
776
|
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
766
|
-
|
777
|
+
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
|
767
778
|
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
|
768
779
|
}
|
769
780
|
}
|
@@ -777,6 +788,7 @@
|
|
777
788
|
updateSelection(cm);
|
778
789
|
setDocumentHeight(cm, barMeasure);
|
779
790
|
updateScrollbars(cm, barMeasure);
|
791
|
+
update.finish();
|
780
792
|
}
|
781
793
|
}
|
782
794
|
|
@@ -2237,6 +2249,8 @@
|
|
2237
2249
|
// Fire change events, and delayed event handlers
|
2238
2250
|
if (op.changeObjs)
|
2239
2251
|
signal(cm, "changes", cm, op.changeObjs);
|
2252
|
+
if (op.update)
|
2253
|
+
op.update.finish();
|
2240
2254
|
}
|
2241
2255
|
|
2242
2256
|
// Run the given function in an operation
|
@@ -2611,8 +2625,10 @@
|
|
2611
2625
|
}
|
2612
2626
|
|
2613
2627
|
function focusInput(cm) {
|
2614
|
-
if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input))
|
2615
|
-
cm.display.input.focus();
|
2628
|
+
if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input)) {
|
2629
|
+
try { cm.display.input.focus(); }
|
2630
|
+
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
2631
|
+
}
|
2616
2632
|
}
|
2617
2633
|
|
2618
2634
|
function ensureFocus(cm) {
|
@@ -5121,7 +5137,7 @@
|
|
5121
5137
|
// FROMTEXTAREA
|
5122
5138
|
|
5123
5139
|
CodeMirror.fromTextArea = function(textarea, options) {
|
5124
|
-
|
5140
|
+
options = options ? copyObj(options) : {};
|
5125
5141
|
options.value = textarea.value;
|
5126
5142
|
if (!options.tabindex && textarea.tabindex)
|
5127
5143
|
options.tabindex = textarea.tabindex;
|
@@ -5152,23 +5168,26 @@
|
|
5152
5168
|
}
|
5153
5169
|
}
|
5154
5170
|
|
5171
|
+
options.finishInit = function(cm) {
|
5172
|
+
cm.save = save;
|
5173
|
+
cm.getTextArea = function() { return textarea; };
|
5174
|
+
cm.toTextArea = function() {
|
5175
|
+
cm.toTextArea = isNaN; // Prevent this from being ran twice
|
5176
|
+
save();
|
5177
|
+
textarea.parentNode.removeChild(cm.getWrapperElement());
|
5178
|
+
textarea.style.display = "";
|
5179
|
+
if (textarea.form) {
|
5180
|
+
off(textarea.form, "submit", save);
|
5181
|
+
if (typeof textarea.form.submit == "function")
|
5182
|
+
textarea.form.submit = realSubmit;
|
5183
|
+
}
|
5184
|
+
};
|
5185
|
+
};
|
5186
|
+
|
5155
5187
|
textarea.style.display = "none";
|
5156
5188
|
var cm = CodeMirror(function(node) {
|
5157
5189
|
textarea.parentNode.insertBefore(node, textarea.nextSibling);
|
5158
5190
|
}, options);
|
5159
|
-
cm.save = save;
|
5160
|
-
cm.getTextArea = function() { return textarea; };
|
5161
|
-
cm.toTextArea = function() {
|
5162
|
-
cm.toTextArea = isNaN; // Prevent this from being ran twice
|
5163
|
-
save();
|
5164
|
-
textarea.parentNode.removeChild(cm.getWrapperElement());
|
5165
|
-
textarea.style.display = "";
|
5166
|
-
if (textarea.form) {
|
5167
|
-
off(textarea.form, "submit", save);
|
5168
|
-
if (typeof textarea.form.submit == "function")
|
5169
|
-
textarea.form.submit = realSubmit;
|
5170
|
-
}
|
5171
|
-
};
|
5172
5191
|
return cm;
|
5173
5192
|
};
|
5174
5193
|
|
@@ -6179,6 +6198,7 @@
|
|
6179
6198
|
function defaultSpecialCharPlaceholder(ch) {
|
6180
6199
|
var token = elt("span", "\u2022", "cm-invalidchar");
|
6181
6200
|
token.title = "\\u" + ch.charCodeAt(0).toString(16);
|
6201
|
+
token.setAttribute("aria-label", token.title);
|
6182
6202
|
return token;
|
6183
6203
|
}
|
6184
6204
|
|
@@ -6212,6 +6232,7 @@
|
|
6212
6232
|
if (m[0] == "\t") {
|
6213
6233
|
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
|
6214
6234
|
var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
6235
|
+
txt.setAttribute("role", "presentation");
|
6215
6236
|
builder.col += tabWidth;
|
6216
6237
|
} else {
|
6217
6238
|
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
@@ -7576,12 +7597,14 @@
|
|
7576
7597
|
return removeChildren(parent).appendChild(e);
|
7577
7598
|
}
|
7578
7599
|
|
7579
|
-
|
7600
|
+
var contains = CodeMirror.contains = function(parent, child) {
|
7580
7601
|
if (parent.contains)
|
7581
7602
|
return parent.contains(child);
|
7582
|
-
while (child = child.parentNode)
|
7603
|
+
while (child = child.parentNode) {
|
7604
|
+
if (child.nodeType == 11) child = child.host;
|
7583
7605
|
if (child == parent) return true;
|
7584
|
-
|
7606
|
+
}
|
7607
|
+
};
|
7585
7608
|
|
7586
7609
|
function activeElt() { return document.activeElement; }
|
7587
7610
|
// Older versions of IE throws unspecified error when touching
|
@@ -8039,7 +8062,7 @@
|
|
8039
8062
|
|
8040
8063
|
// THE END
|
8041
8064
|
|
8042
|
-
CodeMirror.version = "4.
|
8065
|
+
CodeMirror.version = "4.13.0";
|
8043
8066
|
|
8044
8067
|
return CodeMirror;
|
8045
8068
|
});
|
@@ -10,6 +10,7 @@
|
|
10
10
|
mod(CodeMirror);
|
11
11
|
})(function(CodeMirror) {
|
12
12
|
var DEFAULT_BRACKETS = "()[]{}''\"\"";
|
13
|
+
var DEFAULT_TRIPLES = "'\"";
|
13
14
|
var DEFAULT_EXPLODE_ON_ENTER = "[]{}";
|
14
15
|
var SPACE_CHAR_REGEX = /\s/;
|
15
16
|
|
@@ -19,13 +20,14 @@
|
|
19
20
|
if (old != CodeMirror.Init && old)
|
20
21
|
cm.removeKeyMap("autoCloseBrackets");
|
21
22
|
if (!val) return;
|
22
|
-
var pairs = DEFAULT_BRACKETS, explode = DEFAULT_EXPLODE_ON_ENTER;
|
23
|
+
var pairs = DEFAULT_BRACKETS, triples = DEFAULT_TRIPLES, explode = DEFAULT_EXPLODE_ON_ENTER;
|
23
24
|
if (typeof val == "string") pairs = val;
|
24
25
|
else if (typeof val == "object") {
|
25
26
|
if (val.pairs != null) pairs = val.pairs;
|
27
|
+
if (val.triples != null) triples = val.triples;
|
26
28
|
if (val.explode != null) explode = val.explode;
|
27
29
|
}
|
28
|
-
var map = buildKeymap(pairs);
|
30
|
+
var map = buildKeymap(pairs, triples);
|
29
31
|
if (explode) map.Enter = buildExplodeHandler(explode);
|
30
32
|
cm.addKeyMap(map);
|
31
33
|
});
|
@@ -52,7 +54,7 @@
|
|
52
54
|
}
|
53
55
|
}
|
54
56
|
|
55
|
-
function buildKeymap(pairs) {
|
57
|
+
function buildKeymap(pairs, triples) {
|
56
58
|
var map = {
|
57
59
|
name : "autoCloseBrackets",
|
58
60
|
Backspace: function(cm) {
|
@@ -85,7 +87,7 @@
|
|
85
87
|
curType = "skipThree";
|
86
88
|
else
|
87
89
|
curType = "skip";
|
88
|
-
} else if (left == right && cur.ch > 1 &&
|
90
|
+
} else if (left == right && cur.ch > 1 && triples.indexOf(left) >= 0 &&
|
89
91
|
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left &&
|
90
92
|
(cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) {
|
91
93
|
curType = "addFour";
|
@@ -131,7 +131,7 @@
|
|
131
131
|
|
132
132
|
function autoCloseSlash(cm) {
|
133
133
|
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
134
|
-
autoCloseCurrent(cm, true);
|
134
|
+
return autoCloseCurrent(cm, true);
|
135
135
|
}
|
136
136
|
|
137
137
|
CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
|
@@ -94,20 +94,26 @@
|
|
94
94
|
}
|
95
95
|
|
96
96
|
function onGutterClick(cm, line, gutter) {
|
97
|
-
var
|
97
|
+
var state = cm.state.foldGutter;
|
98
|
+
if (!state) return;
|
99
|
+
var opts = state.options;
|
98
100
|
if (gutter != opts.gutter) return;
|
99
101
|
cm.foldCode(Pos(line, 0), opts.rangeFinder);
|
100
102
|
}
|
101
103
|
|
102
104
|
function onChange(cm) {
|
103
|
-
var state = cm.state.foldGutter
|
105
|
+
var state = cm.state.foldGutter;
|
106
|
+
if (!state) return;
|
107
|
+
var opts = state.options;
|
104
108
|
state.from = state.to = 0;
|
105
109
|
clearTimeout(state.changeUpdate);
|
106
110
|
state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
|
107
111
|
}
|
108
112
|
|
109
113
|
function onViewportChange(cm) {
|
110
|
-
var state = cm.state.foldGutter
|
114
|
+
var state = cm.state.foldGutter;
|
115
|
+
if (!state) return;
|
116
|
+
var opts = state.options;
|
111
117
|
clearTimeout(state.changeUpdate);
|
112
118
|
state.changeUpdate = setTimeout(function() {
|
113
119
|
var vp = cm.getViewport();
|
@@ -129,7 +135,9 @@
|
|
129
135
|
}
|
130
136
|
|
131
137
|
function onFold(cm, from) {
|
132
|
-
var state = cm.state.foldGutter
|
138
|
+
var state = cm.state.foldGutter;
|
139
|
+
if (!state) return;
|
140
|
+
var line = from.line;
|
133
141
|
if (line >= state.from && line < state.to)
|
134
142
|
updateFoldInfo(cm, line, line + 1);
|
135
143
|
}
|
@@ -24,6 +24,18 @@
|
|
24
24
|
return cm.showHint(newOpts);
|
25
25
|
};
|
26
26
|
|
27
|
+
var asyncRunID = 0;
|
28
|
+
function retrieveHints(getter, cm, options, then) {
|
29
|
+
if (getter.async) {
|
30
|
+
var id = ++asyncRunID;
|
31
|
+
getter(cm, function(hints) {
|
32
|
+
if (asyncRunID == id) then(hints);
|
33
|
+
}, options);
|
34
|
+
} else {
|
35
|
+
then(getter(cm, options));
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
27
39
|
CodeMirror.defineExtension("showHint", function(options) {
|
28
40
|
// We want a single cursor position.
|
29
41
|
if (this.listSelections().length > 1 || this.somethingSelected()) return;
|
@@ -34,10 +46,7 @@
|
|
34
46
|
if (!getHints) return;
|
35
47
|
|
36
48
|
CodeMirror.signal(this, "startCompletion", this);
|
37
|
-
|
38
|
-
getHints(this, function(hints) { completion.showHints(hints); }, completion.options);
|
39
|
-
else
|
40
|
-
return completion.showHints(getHints(this, completion.options));
|
49
|
+
return retrieveHints(getHints, this, completion.options, function(hints) { completion.showHints(hints); });
|
41
50
|
});
|
42
51
|
|
43
52
|
function Completion(cm, options) {
|
@@ -102,11 +111,7 @@
|
|
102
111
|
function update() {
|
103
112
|
if (finished) return;
|
104
113
|
CodeMirror.signal(data, "update");
|
105
|
-
|
106
|
-
if (getHints.async)
|
107
|
-
getHints(completion.cm, finishUpdate, completion.options);
|
108
|
-
else
|
109
|
-
finishUpdate(getHints(completion.cm, completion.options));
|
114
|
+
retrieveHints(completion.options.hint, completion.cm, completion.options, finishUpdate);
|
110
115
|
}
|
111
116
|
function finishUpdate(data_) {
|
112
117
|
data = data_;
|
@@ -26,9 +26,26 @@
|
|
26
26
|
return CodeMirror.resolveMode(mode).keywords;
|
27
27
|
}
|
28
28
|
|
29
|
+
function getText(item) {
|
30
|
+
return typeof item == "string" ? item : item.text;
|
31
|
+
}
|
32
|
+
|
33
|
+
function getItem(list, item) {
|
34
|
+
if (!list.slice) return list[item];
|
35
|
+
for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
|
36
|
+
return list[i];
|
37
|
+
}
|
38
|
+
|
39
|
+
function shallowClone(object) {
|
40
|
+
var result = {};
|
41
|
+
for (var key in object) if (object.hasOwnProperty(key))
|
42
|
+
result[key] = object[key];
|
43
|
+
return result;
|
44
|
+
}
|
45
|
+
|
29
46
|
function match(string, word) {
|
30
47
|
var len = string.length;
|
31
|
-
var sub = word.substr(0, len);
|
48
|
+
var sub = getText(word).substr(0, len);
|
32
49
|
return string.toUpperCase() === sub.toUpperCase();
|
33
50
|
}
|
34
51
|
|
@@ -44,53 +61,81 @@
|
|
44
61
|
}
|
45
62
|
}
|
46
63
|
|
64
|
+
function cleanName(name) {
|
65
|
+
// Get rid name from backticks(`) and preceding dot(.)
|
66
|
+
if (name.charAt(0) == ".") {
|
67
|
+
name = name.substr(1);
|
68
|
+
}
|
69
|
+
return name.replace(/`/g, "");
|
70
|
+
}
|
71
|
+
|
72
|
+
function insertBackticks(name) {
|
73
|
+
var nameParts = getText(name).split(".");
|
74
|
+
for (var i = 0; i < nameParts.length; i++)
|
75
|
+
nameParts[i] = "`" + nameParts[i] + "`";
|
76
|
+
var escaped = nameParts.join(".");
|
77
|
+
if (typeof name == "string") return escaped;
|
78
|
+
name = shallowClone(name);
|
79
|
+
name.text = escaped;
|
80
|
+
return name;
|
81
|
+
}
|
82
|
+
|
47
83
|
function nameCompletion(cur, token, result, editor) {
|
48
|
-
|
49
|
-
var
|
50
|
-
var
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if (!tables.hasOwnProperty(table))
|
65
|
-
table = findTableByAlias(table, editor);
|
66
|
-
var columns = tables[table];
|
67
|
-
if (!columns) return;
|
68
|
-
|
69
|
-
if (useBacktick) {
|
70
|
-
addMatches(result, string, columns, function(w) {return "`" + w + "`";});
|
71
|
-
}
|
72
|
-
else if(useBacktickTable) {
|
73
|
-
addMatches(result, string, columns, function(w) {return ".`" + w + "`";});
|
74
|
-
}
|
75
|
-
else {
|
76
|
-
addMatches(result, string, columns, function(w) {return "." + w;});
|
84
|
+
// Try to complete table, colunm names and return start position of completion
|
85
|
+
var useBacktick = false;
|
86
|
+
var nameParts = [];
|
87
|
+
var start = token.start;
|
88
|
+
var cont = true;
|
89
|
+
while (cont) {
|
90
|
+
cont = (token.string.charAt(0) == ".");
|
91
|
+
useBacktick = useBacktick || (token.string.charAt(0) == "`");
|
92
|
+
|
93
|
+
start = token.start;
|
94
|
+
nameParts.unshift(cleanName(token.string));
|
95
|
+
|
96
|
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
97
|
+
if (token.string == ".") {
|
98
|
+
cont = true;
|
99
|
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
77
100
|
}
|
78
101
|
}
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
102
|
+
|
103
|
+
// Try to complete table names
|
104
|
+
var string = nameParts.join(".");
|
105
|
+
addMatches(result, string, tables, function(w) {
|
106
|
+
return useBacktick ? insertBackticks(w) : w;
|
107
|
+
});
|
108
|
+
|
109
|
+
// Try to complete columns from defaultTable
|
110
|
+
addMatches(result, string, defaultTable, function(w) {
|
111
|
+
return useBacktick ? insertBackticks(w) : w;
|
112
|
+
});
|
113
|
+
|
114
|
+
// Try to complete columns
|
115
|
+
string = nameParts.pop();
|
116
|
+
var table = nameParts.join(".");
|
117
|
+
|
118
|
+
// Check if table is available. If not, find table by Alias
|
119
|
+
if (!getItem(tables, table))
|
120
|
+
table = findTableByAlias(table, editor);
|
121
|
+
|
122
|
+
var columns = getItem(tables, table);
|
123
|
+
if (columns && Array.isArray(tables) && columns.columns)
|
124
|
+
columns = columns.columns;
|
125
|
+
|
126
|
+
if (columns) {
|
127
|
+
addMatches(result, string, columns, function(w) {
|
128
|
+
if (typeof w == "string") {
|
129
|
+
w = table + "." + w;
|
130
|
+
} else {
|
131
|
+
w = shallowClone(w);
|
132
|
+
w.text = table + "." + w.text;
|
133
|
+
}
|
134
|
+
return useBacktick ? insertBackticks(w) : w;
|
135
|
+
});
|
93
136
|
}
|
137
|
+
|
138
|
+
return start;
|
94
139
|
}
|
95
140
|
|
96
141
|
function eachWord(lineText, f) {
|
@@ -150,12 +195,10 @@
|
|
150
195
|
var lineText = query[i];
|
151
196
|
eachWord(lineText, function(word) {
|
152
197
|
var wordUpperCase = word.toUpperCase();
|
153
|
-
if (wordUpperCase === aliasUpperCase && tables
|
154
|
-
|
155
|
-
|
156
|
-
if (wordUpperCase !== CONS.ALIAS_KEYWORD) {
|
198
|
+
if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
|
199
|
+
table = previousWord;
|
200
|
+
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
|
157
201
|
previousWord = word;
|
158
|
-
}
|
159
202
|
});
|
160
203
|
if (table) break;
|
161
204
|
}
|
@@ -165,7 +208,7 @@
|
|
165
208
|
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
166
209
|
tables = (options && options.tables) || {};
|
167
210
|
var defaultTableName = options && options.defaultTable;
|
168
|
-
defaultTable = (defaultTableName && tables
|
211
|
+
defaultTable = (defaultTableName && getItem(tables, defaultTableName)) || [];
|
169
212
|
keywords = keywords || getKeywords(editor);
|
170
213
|
|
171
214
|
var cur = editor.getCursor();
|
@@ -185,7 +228,7 @@
|
|
185
228
|
search = "";
|
186
229
|
}
|
187
230
|
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
188
|
-
nameCompletion(cur, token, result, editor);
|
231
|
+
start = nameCompletion(cur, token, result, editor);
|
189
232
|
} else {
|
190
233
|
addMatches(result, search, tables, function(w) {return w;});
|
191
234
|
addMatches(result, search, defaultTable, function(w) {return w;});
|