summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/repo_editor.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/components/repo_editor.vue')
-rw-r--r--app/assets/javascripts/ide/components/repo_editor.vue19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/assets/javascripts/ide/components/repo_editor.vue b/app/assets/javascripts/ide/components/repo_editor.vue
index 1f029612c29..a9c05f2e1ac 100644
--- a/app/assets/javascripts/ide/components/repo_editor.vue
+++ b/app/assets/javascripts/ide/components/repo_editor.vue
@@ -74,8 +74,11 @@ export default {
fileEditor() {
return getFileEditorOrDefault(this.fileEditors, this.file.path);
},
+ isBinaryFile() {
+ return !isTextFile(this.file);
+ },
shouldHideEditor() {
- return this.file && !this.file.loading && !isTextFile(this.file);
+ return this.file && !this.file.loading && this.isBinaryFile;
},
showContentViewer() {
return (
@@ -216,7 +219,7 @@ export default {
.then(() => {
this.createEditorInstance();
})
- .catch(err => {
+ .catch((err) => {
flash(
__('Error setting up editor. Please try again.'),
'alert',
@@ -244,6 +247,10 @@ export default {
);
},
createEditorInstance() {
+ if (this.isBinaryFile) {
+ return;
+ }
+
this.editor.dispose();
this.$nextTick(() => {
@@ -274,7 +281,7 @@ export default {
this.model.updateOptions(this.rules);
- this.model.onChange(model => {
+ this.model.onChange((model) => {
const { file } = model;
if (!file.active) return;
@@ -322,7 +329,7 @@ export default {
}
},
fetchEditorconfigRules() {
- return getRulesWithTraversal(this.file.path, path => {
+ return getRulesWithTraversal(this.file.path, (path) => {
const entry = this.entries[path];
if (!entry) return Promise.resolve(null);
@@ -332,7 +339,7 @@ export default {
return this.getFileData({ path: entry.path, makeFileActive: false }).then(() =>
this.getRawFileData({ path: entry.path }),
);
- }).then(rules => {
+ }).then((rules) => {
this.rules = mapRulesToMonaco(rules);
});
},
@@ -346,7 +353,7 @@ export default {
event.preventDefault();
event.stopImmediatePropagation();
- return readFileAsDataURL(file).then(content => {
+ return readFileAsDataURL(file).then((content) => {
const parentPath = getPathParent(this.file.path);
const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`;