Skip to content

Commit 92fd7ac

Browse files
committed
use default theme if theme doesn't exist
1 parent 90b490c commit 92fd7ac

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

browser/finder/ipcClient.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { remote, ipcRenderer } = require('electron')
33
const { app, Menu } = remote
44
const path = require('path')
55
const store = require('./store')
6+
const consts = require('browser/lib/consts')
67

78
nodeIpc.config.id = 'finder'
89
nodeIpc.config.retry = 1500
@@ -94,6 +95,11 @@ nodeIpc.connectTo(
9495
editorTheme.setAttribute('rel', 'stylesheet')
9596
document.head.appendChild(editorTheme)
9697
}
98+
99+
config.editor.theme = consts.THEMES.some((theme) => theme === config.editor.theme)
100+
? config.editor.theme
101+
: 'default'
102+
97103
if (config.editor.theme !== 'default') {
98104
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css')
99105
}

browser/lib/consts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const consts = {
3030
'Dodger Blue',
3131
'Violet Eggplant'
3232
],
33-
THEMES: themes
33+
THEMES: ['default'].concat(themes)
3434
}
3535

3636
module.exports = consts

browser/main/lib/ConfigManager.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import _ from 'lodash'
33
const OSX = global.process.platform === 'darwin'
44
const electron = require('electron')
55
const { ipcRenderer } = electron
6+
const consts = require('browser/lib/consts')
67

78
let isInitialized = false
89

@@ -75,6 +76,11 @@ function get () {
7576
editorTheme.setAttribute('rel', 'stylesheet')
7677
document.head.appendChild(editorTheme)
7778
}
79+
80+
config.editor.theme = consts.THEMES.some((theme) => theme === config.editor.theme)
81+
? config.editor.theme
82+
: 'default'
83+
7884
if (config.editor.theme !== 'default') {
7985
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + config.editor.theme + '.css')
8086
}
@@ -102,7 +108,13 @@ function set (updates) {
102108
editorTheme.setAttribute('rel', 'stylesheet')
103109
document.head.appendChild(editorTheme)
104110
}
105-
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + newConfig.editor.theme + '.css')
111+
let newTheme = consts.THEMES.some((theme) => theme === newConfig.editor.theme)
112+
? newConfig.editor.theme
113+
: 'default'
114+
115+
if (newTheme !== 'default') {
116+
editorTheme.setAttribute('href', '../node_modules/codemirror/theme/' + newTheme + '.css')
117+
}
106118

107119
ipcRenderer.send('config-renew', {
108120
config: get()

0 commit comments

Comments
 (0)