Commit 382033dd authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Tidy monaco model code

parent 6448368b
...@@ -39,14 +39,12 @@ export default class RepoEditor { ...@@ -39,14 +39,12 @@ export default class RepoEditor {
data: () => Store, data: () => Store,
created() { created() {
this.showHide(); this.showHide();
if (this.blobRaw !== '') {
this.monacoInstance.setModel( if (this.blobRaw === '') return;
monaco.editor.createModel(
this.blobRaw, const newModel = monaco.editor.createModel(this.blobRaw, 'plaintext');
'plain',
), this.monacoInstance.setModel(newModel);
);
}
}, },
methods: { methods: {
...@@ -102,21 +100,15 @@ export default class RepoEditor { ...@@ -102,21 +100,15 @@ export default class RepoEditor {
blobRaw() { blobRaw() {
this.showHide(); this.showHide();
if (!this.isTree) { if (this.isTree) return;
// kill the current model;
this.monacoInstance.setModel(null); this.monacoInstance.setModel(null);
// then create the new one
this.monacoInstance.setModel( const languages = monaco.languages.getLanguages();
monaco.editor.createModel( const languageID = Helper.getLanguageIDForFile(this.activeFile, languages);
this.blobRaw, const newModel = monaco.editor.createModel(this.blobRaw, languageID);
Helper
.getLanguageIDForFile( this.monacoInstance.setModel(newModel);
this.activeFile,
monaco.languages.getLanguages(),
),
),
);
}
}, },
}, },
}); });
......
...@@ -19,7 +19,7 @@ const RepoHelper = { ...@@ -19,7 +19,7 @@ const RepoHelper = {
const ext = file.name.split('.').pop(); const ext = file.name.split('.').pop();
const foundLang = this.findLanguage(ext, langs); const foundLang = this.findLanguage(ext, langs);
return foundLang ? foundLang.id : 'plain'; return foundLang ? foundLang.id : 'plaintext';
}, },
findLanguage(ext, langs) { findLanguage(ext, langs) {
......
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