Merge pull request #3968 from lee-dohm/default-themes

Load the default themes when configured themes don't exist
This commit is contained in:
Kevin Sawicki 2014-10-30 09:38:11 -07:00
commit b3f6b3af4b
2 changed files with 10 additions and 17 deletions

View File

@ -308,24 +308,17 @@ describe "ThemeManager", ->
expect(stylesheetsChangedHandler).toHaveBeenCalled()
describe "when a non-existent theme is present in the config", ->
it "logs a warning but does not throw an exception (regression)", ->
reloaded = false
beforeEach ->
atom.config.set('core.themes', ['non-existent-dark-ui', 'non-existent-dark-syntax'])
waitsForPromise ->
themeManager.activateThemes()
runs ->
disposable = themeManager.onDidReloadAll ->
disposable.dispose()
reloaded = true
spyOn(console, 'warn')
expect(-> atom.config.set('core.themes', ['atom-light-ui', 'theme-really-does-not-exist'])).not.toThrow()
waitsFor -> reloaded
runs ->
expect(console.warn.callCount).toBe 1
expect(console.warn.argsForCall[0][0].length).toBeGreaterThan 0
it 'uses the default dark UI and syntax themes', ->
activeThemeNames = themeManager.getActiveNames()
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-dark-ui')
expect(activeThemeNames).toContain('atom-dark-syntax')
describe "when in safe mode", ->
beforeEach ->

View File

@ -161,9 +161,9 @@ class ThemeManager
themeNames = themeNames.filter (themeName) ->
themeName and typeof themeName is 'string'
# Use a built-in syntax and UI theme when in safe mode since themes
# installed to ~/.atom/packages will not be loaded.
if @safeMode
# Use a built-in syntax and UI theme any time the configured themes are not
# available.
if _.intersection(themeNames, atom.packages.getAvailablePackageNames()).length < 2
builtInThemeNames = [
'atom-dark-syntax'
'atom-dark-ui'