(newLangId: LanguageKey, firstTime?: boolean)
| 1873 | } |
| 1874 | |
| 1875 | onLanguageChange(newLangId: LanguageKey, firstTime?: boolean): void { |
| 1876 | const languages = languagesService.getLanguagesOrFail(); |
| 1877 | if (newLangId in languages) { |
| 1878 | if (firstTime || newLangId !== this.currentLanguage?.id) { |
| 1879 | const oldLangId = this.currentLanguage?.id; |
| 1880 | this.currentLanguage = languages[newLangId]; |
| 1881 | if (!this.waitingForLanguage && !this.settings.keepSourcesOnLangChange && newLangId !== 'cmake') { |
| 1882 | this.editorSourceByLang[oldLangId ?? ''] = this.getSource(); |
| 1883 | this.updateEditorCode(); |
| 1884 | } |
| 1885 | this.initLoadSaver(); |
| 1886 | const editorModel = this.editor.getModel(); |
| 1887 | if (editorModel && this.currentLanguage) |
| 1888 | monaco.editor.setModelLanguage(editorModel, this.currentLanguage.monaco); |
| 1889 | this.isCpp.set(this.currentLanguage?.id === 'c++'); |
| 1890 | this.isClean.set(this.currentLanguage?.id === 'clean'); |
| 1891 | this.updateLanguageTooltip(); |
| 1892 | this.updateTitle(); |
| 1893 | this.updateState(); |
| 1894 | // Broadcast the change to other panels |
| 1895 | this.eventHub.emit('languageChange', this.id, newLangId); |
| 1896 | this.decorations = {}; |
| 1897 | if (!firstTime) { |
| 1898 | this.maybeEmitChange(true); |
| 1899 | } |
| 1900 | } |
| 1901 | this.waitingForLanguage = false; |
| 1902 | } |
| 1903 | } |
| 1904 | |
| 1905 | override getDefaultPaneName(): string { |
| 1906 | return 'Editor'; |
no test coverage detected