Commit eb6692ab authored by Phil Hughes's avatar Phil Hughes

fixed content changing across different files

parent 1ff2ac38
......@@ -83,12 +83,12 @@ export default {
this.editor.attachModel(this.model);
this.model.onChange((model) => {
const { file } = this.model;
const { file } = model;
if (file.active) {
this.changeFileContent({
file,
content: model.getValue(),
content: model.getModel().getValue(),
});
}
});
......
......@@ -61,7 +61,7 @@ export default class Model {
this.events.set(
this.path,
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 = (
raw: entry.content,
}, { 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);
});
......
......@@ -39,6 +39,7 @@ export const DISCARD_FILE_CHANGES = 'DISCARD_FILE_CHANGES';
export const CREATE_TMP_FILE = 'CREATE_TMP_FILE';
export const ADD_FILE_TO_CHANGED = 'ADD_FILE_TO_CHANGED';
export const REMOVE_FILE_FROM_CHANGED = 'REMOVE_FILE_FROM_CHANGED';
export const TOGGLE_FILE_CHANGED = 'TOGGLE_FILE_CHANGED';
// Viewer mutation types
export const SET_PREVIEW_MODE = 'SET_PREVIEW_MODE';
......
......@@ -79,4 +79,9 @@ export default {
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', () => {
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