diff --git a/static/panes/editor.js b/static/panes/editor.js index b98cd0214..c913275fc 100644 --- a/static/panes/editor.js +++ b/static/panes/editor.js @@ -944,7 +944,7 @@ Editor.prototype.onLanguageChange = function (newLangId) { if (newLangId !== this.currentLanguage.id) { var oldLangId = this.currentLanguage.id; this.currentLanguage = languages[newLangId]; - if (!this.waitingForLanguage) { + if (!this.waitingForLanguage && !this.settings.keepSourcesOnLangChange) { this.editorSourceByLang[oldLangId] = this.getSource(); this.updateEditorCode(); } diff --git a/static/settings.js b/static/settings.js index dc6bd259a..916841a4c 100644 --- a/static/settings.js +++ b/static/settings.js @@ -229,6 +229,7 @@ function setupSettings(root, settings, onChange, subLangId) { add(root.find('.editorsFLigatures'), 'editorsFLigatures', false, Checkbox); add(root.find('.allowStoreCodeDebug'), 'allowStoreCodeDebug', true, Checkbox); add(root.find('.useVim'), 'useVim', false, Checkbox); + add(root.find('.keepSourcesOnLangChange'), 'keepSourcesOnLangChange', false, Checkbox); setSettings(settings); handleThemes(); diff --git a/views/popups.pug b/views/popups.pug index f12aca3c2..efc346823 100644 --- a/views/popups.pug +++ b/views/popups.pug @@ -145,6 +145,10 @@ label input.showMinimap(type="checkbox") | Show editor minimap + .checkbox + label + input.keepSourcesOnLangChange(type="checkbox") + | Keep editor source on language change div label |  Tab width