Skip to content

Commit 2d52676

Browse files
author
linzhijun
committed
fix
1 parent d4d8c3e commit 2d52676

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

HtmlEditor/ace/ext-language_tools.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HtmlEditor/ace/ext-language_tools.src.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ define("ace/autocomplete", ["require", "exports", "module", "ace/keyboard/hash_h
17611761
results.push(item);
17621762
}
17631763
loop2: for (var i = 0, item; item = items[i]; i++) {
1764-
var caption = item.pinyin;
1764+
var caption = item.meta;
17651765
if (!caption)
17661766
continue;
17671767
var lastIndex = -1;
@@ -1800,6 +1800,46 @@ define("ace/autocomplete", ["require", "exports", "module", "ace/keyboard/hash_h
18001800
item.$score = (item.score || 0) - penalty;
18011801
results.push(item);
18021802
}
1803+
loop3: for (var i = 0, item; item = items[i]; i++) {
1804+
var caption = item.pinyin;
1805+
if (!caption)
1806+
continue;
1807+
var lastIndex = -1;
1808+
var matchMask = 0;
1809+
var penalty = 0;
1810+
var index, distance;
1811+
if (this.exactMatch) {
1812+
if (needle !== caption.substr(0, needle.length))
1813+
continue loop3;
1814+
}
1815+
else {
1816+
var fullMatchIndex = caption.toLowerCase().indexOf(lower);
1817+
if (fullMatchIndex > -1) {
1818+
penalty = fullMatchIndex;
1819+
}
1820+
else {
1821+
for (var j = 0; j < needle.length; j++) {
1822+
var i1 = caption.indexOf(lower[j], lastIndex + 1);
1823+
var i2 = caption.indexOf(upper[j], lastIndex + 1);
1824+
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
1825+
if (index < 0)
1826+
continue loop3;
1827+
distance = index - lastIndex - 1;
1828+
if (distance > 0) {
1829+
if (lastIndex === -1)
1830+
penalty += 10;
1831+
penalty += distance;
1832+
matchMask = matchMask | (1 << j);
1833+
}
1834+
lastIndex = index;
1835+
}
1836+
}
1837+
}
1838+
item.matchMask = matchMask;
1839+
item.exactMatch = penalty ? 0 : 1;
1840+
item.$score = (item.score || 0) - penalty;
1841+
results.push(item);
1842+
}
18031843
return results;
18041844
};
18051845
}).call(FilteredList.prototype);

HtmlEditor/createEditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ace.config.setModuleUrl('ace/mode/my-mode', 'my-mode.js');
33
ace.config.setModuleUrl('ace/worker/my-worker', 'my-worker.js');
44
ace.mymodeFirstCreate = true;
55
ace.jsmodeFirstCreate = true;
6-
window.createEditor=function(id, outId) {
6+
window.createEditor = function (id, outId) {
77
var editor = ace.edit(id);
88
editor.getSession().setMode('ace/mode/my-mode');
99
editor.setTheme("ace/theme/crimson_editor");
@@ -35,7 +35,7 @@ window.createEditor=function(id, outId) {
3535
getCompletions: function (editor, session, pos, prefix, callback) {
3636
if (editor.getSession().getMode().$id != 'ace/mode/my-mode') { callback(null, []); return }
3737
if (prefix.length === 0) { callback(null, []); return }
38-
callback(null, ace_keywords.map(function (ea) { return { pinyin: ea.pinyin, caption: ea.caption, name: ea.text, value: ea.text, meta: ea.meta } }));
38+
callback(null, ace_keywords.map(function (ea) { return { caption: ea.caption, pinyin: ea.pinyin, name: ea.text, value: ea.text, meta: ea.meta } }));
3939
}
4040
}
4141
langTools.addCompleter(rhymeCompleter);

HtmlEditor/my-keywords.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ ace_keywords = [{
256256
"meta": "调和平均值"
257257
}, {
258258
"caption": "has",
259-
"text": "has(文本)",
260-
"meta": "...包含"
259+
"text": "has(json/数组,文本)",
260+
"meta": "包含"
261261
}, {
262262
"caption": "hour",
263263
"text": "hour(日期)",

0 commit comments

Comments
 (0)