Skip to content

Commit d68742a

Browse files
committed
Merge remote-tracking branch 'codemirror/master'
2 parents e5e1ba9 + 79193c0 commit d68742a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1246
-121
lines changed

AUTHORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Daniel, Dao Quang Minh
124124
Daniele Di Sarli
125125
Daniel Faust
126126
Daniel Huigens
127+
Daniel Kesler
127128
Daniel KJ
128129
Daniel Neel
129130
Daniel Parnell
@@ -186,6 +187,7 @@ gekkoe
186187
Gerard Braad
187188
Gergely Hegykozi
188189
Giovanni Calò
190+
Glebov Boris
189191
Glenn Jorde
190192
Glenn Ruehle
191193
Golevka
@@ -255,6 +257,7 @@ John Engler
255257
John Lees-Miller
256258
John Snelson
257259
John Van Der Loo
260+
Jon Ander Peñalba
258261
Jonas Döbertin
259262
Jonathan Malmaud
260263
jongalloway
@@ -414,6 +417,7 @@ Patrick Stoica
414417
Patrick Strawderman
415418
Paul Garvin
416419
Paul Ivanov
420+
Pavel
417421
Pavel Feldman
418422
Pavel Strashkin
419423
Paweł Bartkiewicz
@@ -481,7 +485,9 @@ Stanislav Oaserele
481485
Stas Kobzar
482486
Stefan Borsje
483487
Steffen Beyer
488+
Steffen Bruchmann
484489
Stephen Lavelle
490+
Steve Champagne
485491
Steve O'Hara
486492
stoskov
487493
Stu Kennedy
@@ -534,6 +540,7 @@ Yassin N. Hassan
534540
YNH Webdev
535541
Yunchi Luo
536542
Yuvi Panda
543+
Zac Anger
537544
Zachary Dremann
538545
Zhang Hao
539546
zziuni

CHANGELOG.md

Lines changed: 684 additions & 0 deletions
Large diffs are not rendered by default.

addon/dialog/dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656

5757
var inp = dialog.getElementsByTagName("input")[0], button;
5858
if (inp) {
59+
inp.focus();
60+
5961
if (options.value) {
6062
inp.value = options.value;
6163
if (options.selectValueOnOpen !== false) {
@@ -79,8 +81,6 @@
7981
});
8082

8183
if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
82-
83-
inp.focus();
8484
} else if (button = dialog.getElementsByTagName("button")[0]) {
8585
CodeMirror.on(button, "click", function() {
8686
close();

addon/hint/show-hint.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@
121121

122122
finishUpdate: function(data, first) {
123123
if (this.data) CodeMirror.signal(this.data, "update");
124-
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
125-
this.data = data;
126124

127125
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
128126
if (this.widget) this.widget.close();
127+
128+
if (data && this.data && isNewCompletion(this.data, data)) return;
129+
this.data = data;
130+
129131
if (data && data.list.length) {
130132
if (picked && data.list.length == 1) {
131133
this.pick(data, 0);
@@ -137,6 +139,11 @@
137139
}
138140
};
139141

142+
function isNewCompletion(old, nw) {
143+
var moved = CodeMirror.cmpPos(nw.from, old.from)
144+
return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
145+
}
146+
140147
function parseOptions(cm, pos, options) {
141148
var editor = cm.options.hintOptions;
142149
var out = {};

addon/hint/sql-hint.js

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
};
2121
var Pos = CodeMirror.Pos;
2222

23+
function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
24+
2325
function getKeywords(editor) {
2426
var mode = editor.doc.modeOption;
2527
if (mode === "sql") mode = "text/x-sql";
@@ -30,10 +32,28 @@
3032
return typeof item == "string" ? item : item.text;
3133
}
3234

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];
35+
function wrapTable(name, value) {
36+
if (isArray(value)) value = {columns: value}
37+
if (!value.text) value.text = name
38+
return value
39+
}
40+
41+
function parseTables(input) {
42+
var result = {}
43+
if (isArray(input)) {
44+
for (var i = input.length - 1; i >= 0; i--) {
45+
var item = input[i]
46+
result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
47+
}
48+
} else if (input) {
49+
for (var name in input)
50+
result[name.toUpperCase()] = wrapTable(name, input[name])
51+
}
52+
return result
53+
}
54+
55+
function getTable(name) {
56+
return tables[name.toUpperCase()]
3757
}
3858

3959
function shallowClone(object) {
@@ -50,11 +70,18 @@
5070
}
5171

5272
function addMatches(result, search, wordlist, formatter) {
53-
for (var word in wordlist) {
54-
if (!wordlist.hasOwnProperty(word)) continue;
55-
if (wordlist.slice) word = wordlist[word];
56-
57-
if (match(search, word)) result.push(formatter(word));
73+
if (isArray(wordlist)) {
74+
for (var i = 0; i < wordlist.length; i++)
75+
if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
76+
} else {
77+
for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
78+
var val = wordlist[word]
79+
if (!val || val === true)
80+
val = word
81+
else
82+
val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
83+
if (match(search, val)) result.push(formatter(val))
84+
}
5885
}
5986
}
6087

@@ -115,13 +142,13 @@
115142
var alias = false;
116143
var aliasTable = table;
117144
// Check if table is available. If not, find table by Alias
118-
if (!getItem(tables, table)) {
145+
if (!getTable(table)) {
119146
var oldTable = table;
120147
table = findTableByAlias(table, editor);
121148
if (table !== oldTable) alias = true;
122149
}
123150

124-
var columns = getItem(tables, table);
151+
var columns = getTable(table);
125152
if (columns && columns.columns)
126153
columns = columns.columns;
127154

@@ -184,7 +211,7 @@
184211
//find valid range
185212
var prevItem = 0;
186213
var current = convertCurToNumber(editor.getCursor());
187-
for (var i=0; i< separator.length; i++) {
214+
for (var i = 0; i < separator.length; i++) {
188215
var _v = convertCurToNumber(separator[i]);
189216
if (current > prevItem && current <= _v) {
190217
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
@@ -199,7 +226,7 @@
199226
var lineText = query[i];
200227
eachWord(lineText, function(word) {
201228
var wordUpperCase = word.toUpperCase();
202-
if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
229+
if (wordUpperCase === aliasUpperCase && getTable(previousWord))
203230
table = previousWord;
204231
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
205232
previousWord = word;
@@ -210,10 +237,10 @@
210237
}
211238

212239
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
213-
tables = (options && options.tables) || {};
240+
tables = parseTables(options && options.tables)
214241
var defaultTableName = options && options.defaultTable;
215242
var disableKeywords = options && options.disableKeywords;
216-
defaultTable = defaultTableName && getItem(tables, defaultTableName);
243+
defaultTable = defaultTableName && getTable(defaultTableName);
217244
keywords = keywords || getKeywords(editor);
218245

219246
if (defaultTableName && !defaultTable)

addon/lint/lint.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,27 @@
186186
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187187
}
188188

189-
function popupSpanTooltip(ann, e) {
189+
function popupTooltips(annotations, e) {
190190
var target = e.target || e.srcElement;
191-
showTooltipFor(e, annotationTooltip(ann), target);
191+
var tooltip = document.createDocumentFragment();
192+
for (var i = 0; i < annotations.length; i++) {
193+
var ann = annotations[i];
194+
tooltip.appendChild(annotationTooltip(ann));
195+
}
196+
showTooltipFor(e, tooltip, target);
192197
}
193198

194199
function onMouseOver(cm, e) {
195200
var target = e.target || e.srcElement;
196201
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
197202
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
198203
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
204+
205+
var annotations = [];
199206
for (var i = 0; i < spans.length; ++i) {
200-
var ann = spans[i].__annotation;
201-
if (ann) return popupSpanTooltip(ann, e);
207+
annotations.push(spans[i].__annotation);
202208
}
209+
if (annotations.length) popupTooltips(annotations, e);
203210
}
204211

205212
CodeMirror.defineOption("lint", false, function(cm, val, old) {

addon/merge/merge.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@
427427

428428
function copyChunk(dv, to, from, chunk) {
429429
if (dv.diffOutOfDate) return;
430-
var start = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431-
to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
432-
start, Pos(chunk.editTo, 0));
430+
var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431+
var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
432+
to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
433433
}
434434

435435
// Merge view, containing 0, 1, or 2 diff views.

demo/merge.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<script src="../mode/css/css.js"></script>
1212
<script src="../mode/javascript/javascript.js"></script>
1313
<script src="../mode/htmlmixed/htmlmixed.js"></script>
14-
<script src="//cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"></script>
14+
<script src="https://cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"></script>
1515
<script src="../addon/merge/merge.js"></script>
1616
<style>
1717
.CodeMirror { line-height: 1.2; }

demo/vim.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232

3333
<article>
3434
<h2>Vim bindings demo</h2>
35+
36+
<p><strong style="color: #c33; text-decoration: none">Note:</strong> The CodeMirror vim bindings do not have an
37+
active maintainer. That means that if you report bugs in it, they are
38+
likely to go unanswered. It also means that if you want to help, you
39+
are very welcome to look
40+
at <a href="https://github.com/codemirror/codemirror/issues?q=is%3Aissue+is%3Aopen+label%3Avim">the
41+
open issues</a> and see which ones you can solve.</p>
42+
3543
<form><textarea id="code" name="code">
3644
#include "syscalls.h"
3745
/* getchar: simple buffered version */

doc/compress.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ <h2>Script compression helper</h2>
3636
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
3737
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
3838
<option value="http://codemirror.net/">HEAD</option>
39+
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.12.0;f=">5.12</option>
3940
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.11.0;f=">5.11</option>
4041
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.10.0;f=">5.10</option>
4142
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.9.0;f=">5.9</option>
@@ -180,6 +181,7 @@ <h2>Script compression helper</h2>
180181
<option value="http://codemirror.net/mode/php/php.js">php.js</option>
181182
<option value="http://codemirror.net/mode/pig/pig.js">pig.js</option>
182183
<option value="http://codemirror.net/mode/properties/properties.js">properties.js</option>
184+
<option value="http://codemirror.net/mode/protobuf/protobuf.js">protobuf.js</option>
183185
<option value="http://codemirror.net/mode/python/python.js">python.js</option>
184186
<option value="http://codemirror.net/mode/puppet/puppet.js">puppet.js</option>
185187
<option value="http://codemirror.net/mode/q/q.js">q.js</option>

0 commit comments

Comments
 (0)