mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Refresh cache when core.themes changes
Previously this wasn't needed because a new cache was created for each stylesheet loaded.
This commit is contained in:
@@ -11,21 +11,25 @@ class LessCompileCache
|
||||
|
||||
@cacheDir: path.join(tmpDir, 'atom-compile-cache', 'less')
|
||||
|
||||
constructor: ({resourcePath}) ->
|
||||
constructor: ({resourcePath, importPaths}) ->
|
||||
@lessSearchPaths = [
|
||||
path.join(resourcePath, 'static', 'variables')
|
||||
path.join(resourcePath, 'static')
|
||||
]
|
||||
|
||||
if importPaths?
|
||||
importPaths = importPaths.concat(@lessSearchPaths)
|
||||
else
|
||||
importPaths = @lessSearchPaths
|
||||
|
||||
@cache = new LessCache
|
||||
cacheDir: @constructor.cacheDir
|
||||
importPaths: @getImportPaths()
|
||||
importPaths: importPaths
|
||||
resourcePath: resourcePath
|
||||
fallbackDir: path.join(resourcePath, 'less-compile-cache')
|
||||
|
||||
@subscribe atom.themes, 'reloaded', => @cache.setImportPaths(@getImportPaths())
|
||||
|
||||
getImportPaths: -> atom.themes.getImportPaths().concat(@lessSearchPaths)
|
||||
setImportPaths: (importPaths=[]) ->
|
||||
@cache.setImportPaths(importPaths.concat(@lessSearchPaths))
|
||||
|
||||
read: (stylesheetPath) -> @cache.readFileSync(stylesheetPath)
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ class ThemeManager
|
||||
themeNames = _.clone(themeNames).reverse()
|
||||
|
||||
@packageManager.activatePackage(themeName) for themeName in themeNames
|
||||
@refreshLessCache()
|
||||
@loadUserStylesheet()
|
||||
@reloadBaseStylesheets()
|
||||
@emit('reloaded')
|
||||
@@ -66,6 +67,10 @@ class ThemeManager
|
||||
@packageManager.deactivatePackage(pack.name) for pack in @getActiveThemes()
|
||||
null
|
||||
|
||||
# Internal-only:
|
||||
refreshLessCache: ->
|
||||
@lessCache?.setImportPaths(@getImportPaths())
|
||||
|
||||
# Public: Set the list of enabled themes.
|
||||
#
|
||||
# * enabledThemeNames: An {Array} of {String} theme names.
|
||||
@@ -148,7 +153,7 @@ class ThemeManager
|
||||
loadLessStylesheet: (lessStylesheetPath) ->
|
||||
unless @lessCache?
|
||||
LessCompileCache = require './less-compile-cache'
|
||||
@lessCache = new LessCompileCache({@resourcePath})
|
||||
@lessCache = new LessCompileCache({@resourcePath, importPaths: @getImportPaths()})
|
||||
|
||||
try
|
||||
@lessCache.read(lessStylesheetPath)
|
||||
|
||||
Reference in New Issue
Block a user