summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/editor/setup.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules/editor/setup.js')
-rw-r--r--app/assets/javascripts/ide/stores/modules/editor/setup.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/editor/setup.js b/app/assets/javascripts/ide/stores/modules/editor/setup.js
index c5a613c6baa..9f3163aa6f5 100644
--- a/app/assets/javascripts/ide/stores/modules/editor/setup.js
+++ b/app/assets/javascripts/ide/stores/modules/editor/setup.js
@@ -1,18 +1,23 @@
import eventHub from '~/ide/eventhub';
import { commitActionTypes } from '~/ide/constants';
-const removeUnusedFileEditors = store => {
+const removeUnusedFileEditors = (store) => {
Object.keys(store.state.editor.fileEditors)
- .filter(path => !store.state.entries[path])
- .forEach(path => store.dispatch('editor/removeFileEditor', path));
+ .filter((path) => !store.state.entries[path])
+ .forEach((path) => store.dispatch('editor/removeFileEditor', path));
};
-export const setupFileEditorsSync = store => {
+export const setupFileEditorsSync = (store) => {
eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => {
+ // Do nothing on file update because the file tree itself hasn't changed.
+ if (type === commitActionTypes.update) {
+ return;
+ }
+
if (type === commitActionTypes.move) {
store.dispatch('editor/renameFileEditor', payload);
} else {
- // The files have changed, but the specific change is not known.
+ // The file tree has changed, but the specific change is not known.
removeUnusedFileEditors(store);
}
});