diff --git a/app/config.js b/app/config.js index 6747acd9..6c2a80a3 100644 --- a/app/config.js +++ b/app/config.js @@ -4,6 +4,7 @@ const {_import, getDefaultConfig} = require('./config/import'); const _openConfig = require('./config/open'); const win = require('./config/windows'); const {cfgPath, cfgDir} = require('./config/paths'); +const {getColorMap} = require('./utils/colors'); const watchers = []; let cfg = {}; @@ -129,6 +130,7 @@ const checkDeprecatedConfig = function() { exports.fixConfigDefaults = decoratedConfig => { const defaultConfig = getDefaultConfig().config; + decoratedConfig.colors = getColorMap(decoratedConfig.colors) || {}; // We must have default colors for xterm css. decoratedConfig.colors = Object.assign({}, defaultConfig.colors, decoratedConfig.colors); return decoratedConfig; diff --git a/lib/utils/colors.js b/app/utils/colors.js similarity index 55% rename from lib/utils/colors.js rename to app/utils/colors.js index f0137f4a..f571edd3 100644 --- a/lib/utils/colors.js +++ b/app/utils/colors.js @@ -19,13 +19,14 @@ const colorList = [ 'grayscale' ]; -export default function getColorList(colors) { - // For backwards compatibility, return early if it's already an array - if (Array.isArray(colors)) { +exports.getColorMap = colors => { + if (!Array.isArray(colors)) { return colors; } - - return colorList.map(colorName => { - return colors[colorName]; - }); -} + return colors.reduce((result, color, index) => { + if (index < colorList.length) { + result[colorList[index]] = color; + } + return result; + }, {}); +}; diff --git a/lib/reducers/ui.js b/lib/reducers/ui.js index a516743f..3a018979 100644 --- a/lib/reducers/ui.js +++ b/lib/reducers/ui.js @@ -20,7 +20,6 @@ import { SESSION_SET_CWD } from '../constants/sessions'; import {UPDATE_AVAILABLE} from '../constants/updater'; -import {values} from '../utils/object'; const allowedCursorShapes = new Set(['BEAM', 'BLOCK', 'UNDERLINE']); const allowedCursorBlinkValues = new Set([true, false]); @@ -200,13 +199,7 @@ const reducer = (state = initial, action) => { } if (config.colors) { - if (Array.isArray(config.colors)) { - const stateColors = Array.isArray(state.colors) ? state.colors : values(state.colors); - - if (stateColors.toString() !== config.colors.toString()) { - ret.colors = config.colors; - } - } else if (JSON.stringify(state.colors) !== JSON.stringify(config.colors)) { + if (JSON.stringify(state.colors) !== JSON.stringify(config.colors)) { ret.colors = config.colors; } }