diff options
author | Phil Hughes <me@iamphill.com> | 2018-03-27 16:39:24 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-03-28 14:08:35 +0100 |
commit | 608a648417267aed11bccc1153481efe245a09e9 (patch) | |
tree | d830727d427f5e5b2e94e83fcd882b806ec1e703 /app/assets | |
parent | babb90a7af6f691739f6d600d00f30b88f697dc4 (diff) | |
download | gitlab-ce-608a648417267aed11bccc1153481efe245a09e9.tar.gz |
added specs
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/ide/stores/mutations/file.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js index 0d878d6c6e5..25faac7c828 100644 --- a/app/assets/javascripts/ide/stores/mutations/file.js +++ b/app/assets/javascripts/ide/stores/mutations/file.js @@ -114,24 +114,30 @@ export default { }), }); } else { - Object.assign(state, { - entries: Object.assign(state.entries, { - [file.path]: Object.assign(state.entries[file.path], { - opened: false, - }), - }), - openFiles: state.openFiles.map(f => { + const openFile = state.openFiles.find(f => f.path === file.path); + const openFiles = state.openFiles + .concat(openFile ? null : file) + .filter(f => f) + .reduce((acc, f) => { if (f.path === file.path) { - return { + return acc.concat({ ...f, active: true, pending: true, key: `pending-${f.key}`, - }; + }); } - return f; + return acc.concat(f); + }, []); + + Object.assign(state, { + entries: Object.assign(state.entries, { + [file.path]: Object.assign(state.entries[file.path], { + opened: false, + }), }), + openFiles, }); } }, |