diff --git a/app/assets/javascripts/ide/stores/modules/editor/mutations.js b/app/assets/javascripts/ide/stores/modules/editor/mutations.js index f332fe9dce96931f858ae860b5b6940682adf781..88b0fe769b16e193265c1986b54eca55c12ea6f0 100644 --- a/app/assets/javascripts/ide/stores/modules/editor/mutations.js +++ b/app/assets/javascripts/ide/stores/modules/editor/mutations.js @@ -2,6 +2,13 @@ import Vue from 'vue'; import * as types from './mutation_types'; import { getFileEditorOrDefault } from './utils'; +const deletePropertyAndReturnNewCopy = (source, property) => { + const fileEditorsCopy = { ...source }; + delete fileEditorsCopy[property]; + + return fileEditorsCopy; +}; + export default { [types.UPDATE_FILE_EDITOR](state, { path, data }) { const editor = getFileEditorOrDefault(state.fileEditors, path); @@ -9,7 +16,7 @@ export default { Vue.set(state.fileEditors, path, Object.assign(editor, data)); }, [types.REMOVE_FILE_EDITOR](state, path) { - Vue.delete(state.fileEditors, path); + state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path); }, [types.RENAME_FILE_EDITOR](state, { path, newPath }) { const existing = state.fileEditors[path]; @@ -19,7 +26,7 @@ export default { return; } - Vue.delete(state.fileEditors, path); + state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path); Vue.set(state.fileEditors, newPath, existing); }, };