This commit is contained in:
Liang Ding 2015-06-14 14:43:09 +08:00
parent 492e74e1e8
commit da9c6079f0
4 changed files with 30 additions and 10 deletions

View File

@ -70,6 +70,7 @@ type conf struct {
Locale string // default locale Locale string // default locale
Playground string // playground directory Playground string // playground directory
AllowRegister bool // allow register or not AllowRegister bool // allow register or not
Autocomplete bool // default autocomplete
} }
// Logger. // Logger.

View File

@ -13,5 +13,6 @@
"WD": "${pwd}", "WD": "${pwd}",
"Locale": "en_US", "Locale": "en_US",
"Playground": "${home}/playground", "Playground": "${home}/playground",
"AllowRegister": true "AllowRegister": true,
"Autocomplete": true
} }

View File

@ -15,6 +15,7 @@
*/ */
var editors = { var editors = {
autocompleteMutex: false,
data: [], data: [],
tabs: {}, tabs: {},
getEditorByPath: function (path) { getEditorByPath: function (path) {
@ -354,6 +355,10 @@ var editors = {
var autocompleteHints = []; var autocompleteHints = [];
if (editors.autocompleteMutex && editor.state.completionActive) {
return;
}
$.ajax({ $.ajax({
async: false, // 同步执行 async: false, // 同步执行
type: 'POST', type: 'POST',
@ -407,9 +412,10 @@ var editors = {
} }
} }
// 清除未保存状态
editor.doc.markClean(); editor.doc.markClean();
$(".edit-panel .tabs > div.current > span").removeClass("changed"); $(".edit-panel .tabs > div.current > span").removeClass("changed");
editors.autocompleteMutex = false;
} }
}); });
@ -842,13 +848,24 @@ var editors = {
$span.removeClass("changed"); $span.removeClass("changed");
} }
}); });
} else {
$(".edit-panel .tabs > div").each(function () { return;
var $span = $(this).find("span:eq(0)"); }
if ($span.attr("title") === cm.options.path) {
$span.addClass("changed"); // changed
}
}); $(".edit-panel .tabs > div").each(function () {
var $span = $(this).find("span:eq(0)");
if ($span.attr("title") === cm.options.path) {
$span.addClass("changed");
}
});
if (config.autocomplete) {
var curLine = cm.doc.getLine(cm.getCursor().line).trim().replace(/\W/, "");
if (0.5 <= Math.random() && "" !== curLine && /^\w+$/.test(curLine)) {
CodeMirror.commands.autocompleteAfterDot(cm);
}
} }
}); });

View File

@ -609,7 +609,8 @@
"editorTheme": '{{.user.Editor.Theme}}', "editorTheme": '{{.user.Editor.Theme}}',
"latestSessionContent": {{.latestSessionContent}}, "latestSessionContent": {{.latestSessionContent}},
"editorTabSize": '{{.user.Editor.TabSize}}', "editorTabSize": '{{.user.Editor.TabSize}}',
"keymap": '{{.user.Keymap}}' "keymap": '{{.user.Keymap}}',
"autocomplete": {{.conf.Autocomplete}}
}; };
// 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数. // 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数.
function newWideRequest() { function newWideRequest() {