Commit eb6692ab authored by Phil Hughes's avatar Phil Hughes

fixed content changing across different files

parent 1ff2ac38
...@@ -83,12 +83,12 @@ export default { ...@@ -83,12 +83,12 @@ export default {
this.editor.attachModel(this.model); this.editor.attachModel(this.model);
this.model.onChange((model) => { this.model.onChange((model) => {
const { file } = this.model; const { file } = model;
if (file.active) { if (file.active) {
this.changeFileContent({ this.changeFileContent({
file, file,
content: model.getValue(), content: model.getModel().getValue(),
}); });
} }
}); });
......
...@@ -61,7 +61,7 @@ export default class Model { ...@@ -61,7 +61,7 @@ export default class Model {
this.events.set( this.events.set(
this.path, this.path,
this.disposable.add( this.disposable.add(
this.model.onDidChangeContent(e => cb(this.model, e)), this.model.onDidChangeContent(e => cb(this, e)),
), ),
); );
} }
......
...@@ -94,7 +94,10 @@ export const updateFilesAfterCommit = ( ...@@ -94,7 +94,10 @@ export const updateFilesAfterCommit = (
raw: entry.content, raw: entry.content,
}, { root: true }); }, { root: true });
commit(rootTypes.DISCARD_FILE_CHANGES, entry, { root: true }); commit(rootTypes.TOGGLE_FILE_CHANGED, {
file: entry,
changed: false,
}, { root: true });
eventHub.$emit(`editor.update.model.content.${entry.path}`, entry.raw); eventHub.$emit(`editor.update.model.content.${entry.path}`, entry.raw);
}); });
......
...@@ -39,6 +39,7 @@ export const DISCARD_FILE_CHANGES = 'DISCARD_FILE_CHANGES'; ...@@ -39,6 +39,7 @@ export const DISCARD_FILE_CHANGES = 'DISCARD_FILE_CHANGES';
export const CREATE_TMP_FILE = 'CREATE_TMP_FILE'; export const CREATE_TMP_FILE = 'CREATE_TMP_FILE';
export const ADD_FILE_TO_CHANGED = 'ADD_FILE_TO_CHANGED'; export const ADD_FILE_TO_CHANGED = 'ADD_FILE_TO_CHANGED';
export const REMOVE_FILE_FROM_CHANGED = 'REMOVE_FILE_FROM_CHANGED'; export const REMOVE_FILE_FROM_CHANGED = 'REMOVE_FILE_FROM_CHANGED';
export const TOGGLE_FILE_CHANGED = 'TOGGLE_FILE_CHANGED';
// Viewer mutation types // Viewer mutation types
export const SET_PREVIEW_MODE = 'SET_PREVIEW_MODE'; export const SET_PREVIEW_MODE = 'SET_PREVIEW_MODE';
......
...@@ -79,4 +79,9 @@ export default { ...@@ -79,4 +79,9 @@ export default {
state.changedFiles.splice(indexOfChangedFile, 1); state.changedFiles.splice(indexOfChangedFile, 1);
}, },
[types.TOGGLE_FILE_CHANGED](state, { file, changed }) {
Object.assign(file, {
changed,
});
},
}; };
...@@ -161,4 +161,17 @@ describe('Multi-file store file mutations', () => { ...@@ -161,4 +161,17 @@ describe('Multi-file store file mutations', () => {
expect(localState.changedFiles.length).toBe(0); expect(localState.changedFiles.length).toBe(0);
}); });
}); });
describe('TOGGLE_FILE_CHANGED', () => {
it('updates file changed status', () => {
const f = file();
mutations.TOGGLE_FILE_CHANGED(localState, {
file: f,
changed: true,
});
expect(f.changed).toBeTruthy();
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment