Fix #230
This commit is contained in:
parent
492e74e1e8
commit
da9c6079f0
|
@ -70,6 +70,7 @@ type conf struct {
|
|||
Locale string // default locale
|
||||
Playground string // playground directory
|
||||
AllowRegister bool // allow register or not
|
||||
Autocomplete bool // default autocomplete
|
||||
}
|
||||
|
||||
// Logger.
|
||||
|
|
|
@ -13,5 +13,6 @@
|
|||
"WD": "${pwd}",
|
||||
"Locale": "en_US",
|
||||
"Playground": "${home}/playground",
|
||||
"AllowRegister": true
|
||||
"AllowRegister": true,
|
||||
"Autocomplete": true
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
var editors = {
|
||||
autocompleteMutex: false,
|
||||
data: [],
|
||||
tabs: {},
|
||||
getEditorByPath: function (path) {
|
||||
|
@ -354,6 +355,10 @@ var editors = {
|
|||
|
||||
var autocompleteHints = [];
|
||||
|
||||
if (editors.autocompleteMutex && editor.state.completionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
async: false, // 同步执行
|
||||
type: 'POST',
|
||||
|
@ -407,9 +412,10 @@ var editors = {
|
|||
}
|
||||
}
|
||||
|
||||
// 清除未保存状态
|
||||
editor.doc.markClean();
|
||||
$(".edit-panel .tabs > div.current > span").removeClass("changed");
|
||||
|
||||
editors.autocompleteMutex = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -842,13 +848,24 @@ var editors = {
|
|||
$span.removeClass("changed");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".edit-panel .tabs > div").each(function () {
|
||||
var $span = $(this).find("span:eq(0)");
|
||||
if ($span.attr("title") === cm.options.path) {
|
||||
$span.addClass("changed");
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -609,7 +609,8 @@
|
|||
"editorTheme": '{{.user.Editor.Theme}}',
|
||||
"latestSessionContent": {{.latestSessionContent}},
|
||||
"editorTabSize": '{{.user.Editor.TabSize}}',
|
||||
"keymap": '{{.user.Keymap}}'
|
||||
"keymap": '{{.user.Keymap}}',
|
||||
"autocomplete": {{.conf.Autocomplete}}
|
||||
};
|
||||
// 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数.
|
||||
function newWideRequest() {
|
||||
|
|
Loading…
Reference in New Issue