diff --git a/src/app/atom.coffee b/src/app/atom.coffee
index 991b12538..95cb4b20a 100644
--- a/src/app/atom.coffee
+++ b/src/app/atom.coffee
@@ -9,7 +9,7 @@ originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess
_.extend atom,
exitWhenDone: window.location.params.exitWhenDone
-
+ loadedThemes: []
pendingBrowserProcessCallbacks: {}
loadPackages: ->
@@ -44,7 +44,11 @@ _.extend atom,
@loadTheme(themeName) for themeName in themeNames
loadTheme: (name) ->
- Theme.load(name)
+ @loadedThemes.push Theme.load(name)
+
+ getAtomThemeStylesheets: ->
+ themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black']
+ themeNames = [themeNames] unless _.isArray(themeNames)
open: (args...) ->
@sendMessageToBrowserProcess('open', args)
diff --git a/src/app/theme.coffee b/src/app/theme.coffee
index 1c42fcbb0..1be21fdbf 100644
--- a/src/app/theme.coffee
+++ b/src/app/theme.coffee
@@ -21,7 +21,6 @@ class Theme
if TextMateTheme.testPath(path)
new TextMateTheme(path)
else
- require.paths.unshift path
new AtomTheme(path)
theme.load()
@@ -32,7 +31,7 @@ class Theme
load: ->
for stylesheetPath, stylesheetContent of @stylesheets
- applyStylesheet(stylesheetPath, stylesheetContent)
+ applyStylesheet(stylesheetPath, stylesheetContent, 'userTheme')
deactivate: ->
for stylesheetPath, stylesheetContent of @stylesheets
diff --git a/src/app/window.coffee b/src/app/window.coffee
index 9e53ed5b6..ea6866ec7 100644
--- a/src/app/window.coffee
+++ b/src/app/window.coffee
@@ -70,18 +70,26 @@ windowAdditions =
$("head style[id='#{id}']")
requireStylesheet: (path) ->
- unless fullPath = require.resolve(path)
+ if fullPath = require.resolve(path)
+ window.applyStylesheet(fullPath, fs.read(fullPath))
+ for theme in atom.loadedThemes
+ for themePath, css of theme.stylesheets
+ matched = true if themePath.match(path)
+ unless fullPath || matched
throw new Error("Could not find a file at path '#{path}'")
- window.applyStylesheet(fullPath, fs.read(fullPath))
removeStylesheet: (path) ->
unless fullPath = require.resolve(path)
throw new Error("Could not find a file at path '#{path}'")
window.stylesheetElementForId(fullPath).remove()
- applyStylesheet: (id, text) ->
+ applyStylesheet: (id, text, ttype = 'bundled') ->
unless window.stylesheetElementForId(id).length
- $('head').append ""
+ if $("head style.#{ttype}").length
+ $("head style.#{ttype}:last").after ""
+ else
+ $("head").append ""
+
reload: ->
if rootView?.getModifiedBuffers().length > 0