mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1033853 - Do not reload files that have changed in project editor. r=harth
This commit is contained in:
parent
0db29c76bc
commit
ce4d9f6dfb
@ -40,6 +40,11 @@ var ItchEditor = Class({
|
||||
emit(this, name, ...args);
|
||||
},
|
||||
|
||||
/* Does the editor not have any unsaved changes? */
|
||||
isClean: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize the editor with a single host. This should be called
|
||||
* by objects extending this object with:
|
||||
@ -145,6 +150,13 @@ var TextEditor = Class({
|
||||
return extraKeys;
|
||||
},
|
||||
|
||||
isClean: function() {
|
||||
if (!this.editor.isAppended()) {
|
||||
return true;
|
||||
}
|
||||
return this.editor.isClean();
|
||||
},
|
||||
|
||||
initialize: function(document, mode=Editor.modes.text) {
|
||||
ItchEditor.prototype.initialize.apply(this, arguments);
|
||||
this.label = mode.name;
|
||||
|
@ -22,9 +22,8 @@ var DirtyPlugin = Class({
|
||||
|
||||
// Dont' force a refresh unless the dirty state has changed...
|
||||
let priv = this.priv(editor);
|
||||
let clean = editor.editor.isClean();
|
||||
let clean = editor.isClean()
|
||||
if (priv.isClean !== clean) {
|
||||
|
||||
let resource = editor.shell.resource;
|
||||
emit(resource, "label-change", resource);
|
||||
priv.isClean = clean;
|
||||
|
@ -192,7 +192,10 @@ var ShellDeck = Class({
|
||||
this.deck.selectedPanel = shell.elt;
|
||||
this._activeShell = shell;
|
||||
|
||||
shell.load();
|
||||
// Only reload the shell if the editor doesn't have local changes.
|
||||
if (shell.editor.isClean()) {
|
||||
shell.load();
|
||||
}
|
||||
shell.editorLoaded.then(() => {
|
||||
// Handle case where another shell has been requested before this
|
||||
// one is finished loading.
|
||||
|
@ -22,9 +22,41 @@ let test = asyncTest(function*() {
|
||||
let resource = resources.filter(r=>r.basename === data.basename)[0];
|
||||
yield selectFile(projecteditor, resource);
|
||||
yield testChangeFileExternally(projecteditor, getTempFile(data.path).path, data.newContent);
|
||||
yield testChangeUnsavedFileExternally(projecteditor, getTempFile(data.path).path, data.newContent + "[changed]");
|
||||
}
|
||||
});
|
||||
|
||||
function testChangeUnsavedFileExternally(projecteditor, filePath, newData) {
|
||||
info ("Testing file external changes for: " + filePath);
|
||||
|
||||
let editor = projecteditor.currentEditor;
|
||||
let resource = projecteditor.resourceFor(editor);
|
||||
let initialData = yield getFileData(filePath);
|
||||
|
||||
is (resource.path, filePath, "Resource path is set correctly");
|
||||
is (editor.editor.getText(), initialData, "Editor is loaded with correct file contents");
|
||||
|
||||
info ("Editing but not saving file in project editor");
|
||||
ok (editor.isClean(), "Editor is clean");
|
||||
editor.editor.setText("foobar");
|
||||
ok (!editor.isClean(), "Editor is dirty");
|
||||
|
||||
info ("Editor has been selected, writing to file externally");
|
||||
yield writeToFile(resource.path, newData);
|
||||
|
||||
info ("Selecting another resource, then reselecting this one");
|
||||
projecteditor.projectTree.selectResource(resource.store.root);
|
||||
yield onceEditorActivated(projecteditor);
|
||||
projecteditor.projectTree.selectResource(resource);
|
||||
yield onceEditorActivated(projecteditor);
|
||||
|
||||
let editor = projecteditor.currentEditor;
|
||||
info ("Checking to make sure the editor is now populated correctly");
|
||||
is (editor.editor.getText(), "foobar", "Editor has not been updated with new file contents");
|
||||
|
||||
info ("Finished checking saving for " + filePath);
|
||||
}
|
||||
|
||||
function testChangeFileExternally(projecteditor, filePath, newData) {
|
||||
info ("Testing file external changes for: " + filePath);
|
||||
|
||||
|
@ -344,6 +344,14 @@ Editor.prototype = {
|
||||
return def.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether the editor is ready to
|
||||
* use. Use appendTo(el).then(() => {}) for most cases
|
||||
*/
|
||||
isAppended: function() {
|
||||
return editors.has(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the currently active highlighting mode.
|
||||
* See Editor.modes for the list of all suppoert modes.
|
||||
|
Loading…
Reference in New Issue
Block a user