mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Merge branch 'master' of github.com:atom/atom
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
"command-palette": "0.10.0",
|
||||
"dev-live-reload": "0.17.0",
|
||||
"editor-stats": "0.7.0",
|
||||
"exception-reporting": "0.7.0",
|
||||
"exception-reporting": "0.8.0",
|
||||
"find-and-replace": "0.48.0",
|
||||
"fuzzy-finder": "0.25.0",
|
||||
"gists": "0.9.0",
|
||||
@@ -102,7 +102,7 @@
|
||||
"styleguide": "0.15.0",
|
||||
"symbols-view": "0.24.0",
|
||||
"tabs": "0.11.0",
|
||||
"terminal": "0.19.0",
|
||||
"terminal": "0.22.0",
|
||||
"timecop": "0.10.0",
|
||||
"to-the-hubs": "0.13.0",
|
||||
"tree-view": "0.38.0",
|
||||
|
||||
@@ -39,7 +39,9 @@ specPackageName = null
|
||||
specPackagePath = null
|
||||
specProjectPath = null
|
||||
|
||||
if specDirectory = atom.getLoadSettings().specDirectory
|
||||
{specDirectory, resourcePath} = atom.getLoadSettings()
|
||||
|
||||
if specDirectory
|
||||
specPackagePath = path.resolve(specDirectory, '..')
|
||||
try
|
||||
specPackageName = fs.readObjectSync(path.join(specPackagePath, 'package.json'))?.name
|
||||
@@ -68,9 +70,7 @@ beforeEach ->
|
||||
spyOn(atom.menu, 'sendToBrowserProcess')
|
||||
|
||||
# reset config before each spec; don't load or save from/to `config.json`
|
||||
config = new Config
|
||||
resourcePath: window.resourcePath
|
||||
configDirPath: atom.getConfigDirPath()
|
||||
config = new Config({resourcePath, configDirPath: atom.getConfigDirPath()})
|
||||
spyOn(config, 'load')
|
||||
spyOn(config, 'save')
|
||||
config.setDefaults('core', RootView.configDefaults)
|
||||
|
||||
@@ -23,9 +23,10 @@ setSpecDirectory = (specDirectory) ->
|
||||
setSpecField('specDirectory', specDirectory)
|
||||
|
||||
runAllSpecs = ->
|
||||
{resourcePath} = atom.getLoadSettings()
|
||||
# Only run core specs when resource path is the Atom repository
|
||||
if Git.exists(window.resourcePath)
|
||||
requireSpecs(path.join(window.resourcePath, 'spec'))
|
||||
if Git.exists(resourcePath)
|
||||
requireSpecs(path.join(resourcePath, 'spec'))
|
||||
setSpecType('core')
|
||||
|
||||
fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages')
|
||||
@@ -34,7 +35,7 @@ runAllSpecs = ->
|
||||
packagePaths = _.groupBy packagePaths, (packagePath) ->
|
||||
if packagePath.indexOf("#{fixturesPackagesPath}#{path.sep}") is 0
|
||||
'fixtures'
|
||||
else if packagePath.indexOf("#{window.resourcePath}#{path.sep}") is 0
|
||||
else if packagePath.indexOf("#{resourcePath}#{path.sep}") is 0
|
||||
'bundled'
|
||||
else
|
||||
'user'
|
||||
|
||||
@@ -307,11 +307,11 @@ class Atom
|
||||
@rootView.trigger 'beep'
|
||||
|
||||
requireUserInitScript: ->
|
||||
userInitScriptPath = path.join(@getConfigDirPath(), "user.coffee")
|
||||
try
|
||||
require userInitScriptPath if fs.isFileSync(userInitScriptPath)
|
||||
catch error
|
||||
console.error "Failed to load `#{userInitScriptPath}`", error.stack, error
|
||||
if userInitScriptPath = fs.resolve(@getConfigDirPath(), 'user', ['js', 'coffee'])
|
||||
try
|
||||
require userInitScriptPath
|
||||
catch error
|
||||
console.error "Failed to load `#{userInitScriptPath}`", error.stack, error
|
||||
|
||||
requireWithGlobals: (id, globals={}) ->
|
||||
existingGlobals = {}
|
||||
|
||||
@@ -159,15 +159,16 @@ class Keymap
|
||||
else
|
||||
if keyBinding.command is 'native!'
|
||||
shouldBubble = true
|
||||
else if @triggerCommandEvent(element, keyBinding.command)
|
||||
else if @triggerCommandEvent(element, keyBinding.command, event)
|
||||
shouldBubble = false
|
||||
|
||||
break if shouldBubble?
|
||||
|
||||
shouldBubble ? true
|
||||
|
||||
triggerCommandEvent: (element, commandName) ->
|
||||
triggerCommandEvent: (element, commandName, event) ->
|
||||
commandEvent = $.Event(commandName)
|
||||
commandEvent.originalEvent = event
|
||||
commandEvent.abortKeyBinding = -> commandEvent.stopImmediatePropagation()
|
||||
$(element).trigger(commandEvent)
|
||||
not commandEvent.isImmediatePropagationStopped()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -27,11 +27,30 @@ class MenuManager
|
||||
@merge(@template, item) for item in items
|
||||
@update()
|
||||
|
||||
# Private: Should the binding for the given selector be included in the menu
|
||||
# commands.
|
||||
#
|
||||
# * selector: A String selector to check.
|
||||
#
|
||||
# Returns true to include the selector, false otherwise.
|
||||
includeSelector: (selector) ->
|
||||
return true if document.body.webkitMatchesSelector(selector)
|
||||
|
||||
# Simulate an .editor element attached to a body element that has the same
|
||||
# classes as the current body element.
|
||||
unless @testEditor?
|
||||
@testEditor = document.createElement('div')
|
||||
@testEditor.classList.add('editor')
|
||||
testBody = document.createElement('body')
|
||||
testBody.classList.add(document.body.classList.toString().split(' ')...)
|
||||
testBody.appendChild(@testEditor)
|
||||
|
||||
@testEditor.webkitMatchesSelector(selector)
|
||||
|
||||
# Public: Refreshes the currently visible menu.
|
||||
update: ->
|
||||
keystrokesByCommand = {}
|
||||
selectors = ['body', ".platform-#{process.platform}", '.editor', '.editor:not(.mini)']
|
||||
for binding in atom.keymap.getKeyBindings() when binding.selector in selectors
|
||||
for binding in atom.keymap.getKeyBindings() when @includeSelector(binding.selector)
|
||||
keystrokesByCommand[binding.command] ?= []
|
||||
keystrokesByCommand[binding.command].push binding.keystroke
|
||||
@sendToBrowserProcess(@template, keystrokesByCommand)
|
||||
@@ -40,8 +59,8 @@ class MenuManager
|
||||
loadPlatformItems: ->
|
||||
menusDirPath = path.join(@resourcePath, 'menus')
|
||||
platformMenuPath = fs.resolve(menusDirPath, process.platform, ['cson', 'json'])
|
||||
data = CSON.readFileSync(platformMenuPath)
|
||||
@add(data.menu)
|
||||
{menu} = CSON.readFileSync(platformMenuPath)
|
||||
@add(menu)
|
||||
|
||||
# Private: Merges an item in a submenu aware way such that new items are always
|
||||
# appended to the bottom of existing menus where possible.
|
||||
|
||||
@@ -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.
|
||||
@@ -146,9 +151,9 @@ class ThemeManager
|
||||
|
||||
# Internal-only:
|
||||
loadLessStylesheet: (lessStylesheetPath) ->
|
||||
unless lessCache?
|
||||
unless @lessCache?
|
||||
LessCompileCache = require './less-compile-cache'
|
||||
@lessCache = new LessCompileCache({@resourcePath})
|
||||
@lessCache = new LessCompileCache({@resourcePath, importPaths: @getImportPaths()})
|
||||
|
||||
try
|
||||
@lessCache.read(lessStylesheetPath)
|
||||
|
||||
@@ -11,7 +11,6 @@ windowEventHandler = null
|
||||
# This method is called in any window needing a general environment, including specs
|
||||
window.setUpEnvironment = (windowMode) ->
|
||||
atom.windowMode = windowMode
|
||||
window.resourcePath = atom.getLoadSettings().resourcePath
|
||||
atom.initialize()
|
||||
|
||||
# Set up the default event handlers and menus for a non-editor windows.
|
||||
@@ -65,11 +64,13 @@ window.unloadEditorWindow = ->
|
||||
windowEventHandler?.unsubscribe()
|
||||
|
||||
installAtomCommand = (callback) ->
|
||||
commandPath = path.join(window.resourcePath, 'atom.sh')
|
||||
{resourcePath} = atom.getLoadSettings()
|
||||
commandPath = path.join(resourcePath, 'atom.sh')
|
||||
require('./command-installer').install(commandPath, callback)
|
||||
|
||||
installApmCommand = (callback) ->
|
||||
commandPath = path.join(window.resourcePath, 'node_modules', '.bin', 'apm')
|
||||
{resourcePath} = atom.getLoadSettings()
|
||||
commandPath = path.join(resourcePath, 'node_modules', '.bin', 'apm')
|
||||
require('./command-installer').install(commandPath, callback)
|
||||
|
||||
window.deserializeEditorWindow = ->
|
||||
|
||||
Reference in New Issue
Block a user