Fixes for responsiveness and retained file loss.
This commit is contained in:
parent
474a18dc11
commit
7275752aef
3 changed files with 40 additions and 21 deletions
|
@ -6,7 +6,6 @@ define([
|
|||
"settings!" //not excited, it just runs as a RequireJS plugin
|
||||
], function(sessions, File, dialog, command, Settings) {
|
||||
|
||||
|
||||
var openFile = function() {
|
||||
var f = new File();
|
||||
f.open(function(err) {
|
||||
|
@ -98,20 +97,38 @@ define([
|
|||
openFromLaunchData();
|
||||
chrome.storage.local.get("retained", function(data) {
|
||||
var failures = [];
|
||||
var successes = [];
|
||||
var attempts = 0;
|
||||
if (data.retained && data.retained.length) {
|
||||
data.retained.forEach(function(id) {
|
||||
var checkFinished = function() {
|
||||
if (attempts >= data.retained.length) {
|
||||
successes = successes.filter(function(t) { return typeof t == "object" });
|
||||
successes.forEach(function(retained) {
|
||||
sessions.addFile(retained.contents, retained.file);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
data.retained.forEach(function(id, index) {
|
||||
var file = new File();
|
||||
file.restore(id, function(err, f) {
|
||||
if (err) {
|
||||
//add failures to be removed asynchronously
|
||||
attempts++;
|
||||
failures.push(id);
|
||||
return;
|
||||
checkFinished();
|
||||
} else {
|
||||
file.read(function(err, contents) {
|
||||
attempts++;
|
||||
if (err) {
|
||||
failures.push(id);
|
||||
} else {
|
||||
successes[index] = {contents: contents, file: file};
|
||||
}
|
||||
checkFinished();
|
||||
});
|
||||
}
|
||||
file.read(function(err, contents) {
|
||||
if (err) return;
|
||||
sessions.addFile(contents, file);
|
||||
});
|
||||
return id;
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -123,7 +140,7 @@ define([
|
|||
retained: data.retained.filter(function(d) { return failures.indexOf(d) == -1 })
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
}, 100);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ define([
|
|||
var whenOpen = function() {
|
||||
self.file.write(content, function() {
|
||||
self.modifiedAt = new Date();
|
||||
c();
|
||||
if (c) c();
|
||||
});
|
||||
self.modified = false;
|
||||
renderTabs();
|
||||
|
@ -199,6 +199,7 @@ define([
|
|||
index = tabs.indexOf(editor.getSession());
|
||||
}
|
||||
var tab = tabs[index];
|
||||
stack = stack.filter(function(t) { return t !== tab });
|
||||
|
||||
var continuation = function() {
|
||||
tab.drop();
|
||||
|
@ -243,23 +244,24 @@ define([
|
|||
command.fire("session:check-file");
|
||||
};
|
||||
|
||||
//keep track of the ctrl key for jumping through the tab stack
|
||||
document.body.on("keydown", function(e) {
|
||||
if (e.keyCode == 17) {
|
||||
stackOffset = 0;
|
||||
}
|
||||
});
|
||||
|
||||
//when ctrl is released, move the current tab to the top
|
||||
document.body.on("keyup", function(e) {
|
||||
var watchCtrl = function(e) {
|
||||
if (e.keyCode == 17) {
|
||||
var raised = stack[stackOffset];
|
||||
stack = stack.filter(function(t) { return t !== raised });
|
||||
stack.unshift(raised);
|
||||
document.body.off("keyup", watchCtrl);
|
||||
ctrl = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var ctrl = false;
|
||||
|
||||
var switchTab = function(shift) {
|
||||
if (!ctrl) {
|
||||
ctrl = true;
|
||||
stackOffset = 0;
|
||||
document.body.on("keyup", watchCtrl);
|
||||
}
|
||||
stackOffset = (stackOffset + 1) % stack.length;
|
||||
stack[stackOffset].raise();
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "Caret",
|
||||
"description": "Professional text editing for Chrome and Chrome OS",
|
||||
"version": "0.0.42",
|
||||
"version": "0.0.43",
|
||||
"manifest_version": 2,
|
||||
"icons": {
|
||||
"128": "icon-128-2.png"
|
||||
|
|
Loading…
Reference in a new issue