use delayedCall instead of setTimeout

This commit is contained in:
nightwing 2013-03-18 21:54:39 +04:00
commit d97de5c149
2 changed files with 15 additions and 17 deletions

View file

@ -98,7 +98,7 @@ var modesByName = {
tex: ["Tex" , "tex"],
text: ["Text" , "txt"],
textile: ["Textile" , "textile"],
tm_snippet: ["tmSnippet" , "tmSnippet"],
tmsnippet: ["tmSnippet" , "tmSnippet"],
toml: ["toml" , "toml"],
typescript: ["Typescript" , "typescript|ts|str"],
vbscript: ["VBScript" , "vbs"],

View file

@ -510,7 +510,7 @@ var TabstopManager = function(editor) {
return editor.tabstopManager;
editor.tabstopManager = this;
this.$onChange = this.onChange.bind(this);
this.$onChangeSelection = this.onChangeSelection.bind(this);
this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
this.$onChangeSession = this.onChangeSession.bind(this);
this.$onAfterExec = this.onAfterExec.bind(this);
this.attach(editor);
@ -606,31 +606,29 @@ var TabstopManager = function(editor) {
var fmt = exports.SnippetManager.tmStrFormat(text, range.original)
session.replace(range, fmt);
}
this.$inChange = false;
};
this.onAfterExec = function(e) {
if (e.command && !e.command.readOnly)
this.updateLinkedFields();
};
this.onChangeSelection = function() {
setTimeout(function() {
if (!this.editor)
return
var lead = this.editor.selection.lead;
var anchor = this.editor.selection.anchor;
var isEmpty = this.editor.selection.isEmpty();
for (var i = this.ranges.length; i--;) {
var containsLead = this.ranges[i].contains(lead.row, lead.column);
var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
if (containsLead && containsAnchor)
return;
}
this.detach();
}.bind(this));
if (!this.editor)
return
var lead = this.editor.selection.lead;
var anchor = this.editor.selection.anchor;
var isEmpty = this.editor.selection.isEmpty();
for (var i = this.ranges.length; i--;) {
var containsLead = this.ranges[i].contains(lead.row, lead.column);
var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
if (containsLead && containsAnchor)
return;
}
this.detach();
};
this.onChangeSession = function() {
this.detach();
};
this.tabNext = function(dir) {
var max = this.tabstops.length - 1;
var index = this.index + (dir || 1);