Merge remote-tracking branch 'refs/remotes/origin/master' into wl-drewmnoel-electron

This commit is contained in:
Wliu
2016-04-12 17:32:07 -04:00
30 changed files with 1211 additions and 80 deletions

View File

@@ -466,6 +466,7 @@ class AtomApplication
openedWindow.restore()
else
openedWindow.focus()
openedWindow.replaceEnvironment(env)
else
if devMode
try

View File

@@ -68,6 +68,7 @@ class AtomWindow
@loaded = true
@setLoadSettings(loadSettings)
@env = loadSettings.env if loadSettings.env?
@browserWindow.focusOnWebView() if @isSpec
@browserWindow.temporaryState = {windowDimensions} if windowDimensions?
@@ -169,6 +170,9 @@ class AtomWindow
else
@browserWindow.once 'window:loaded', => @openLocations(locationsToOpen)
replaceEnvironment: (env) ->
@browserWindow.webContents.send 'environment', env
sendMessage: (message, detail) ->
@browserWindow.webContents.send 'message', message, detail

View File

@@ -67,7 +67,7 @@ class BufferedProcess
cmdArgs.unshift("\"#{command}\"")
else
cmdArgs.unshift(command)
cmdArgs = ['/s', '/c', "\"#{cmdArgs.join(' ')}\""]
cmdArgs = ['/s', '/d', '/c', "\"#{cmdArgs.join(' ')}\""]
cmdOptions = _.clone(options)
cmdOptions.windowsVerbatimArguments = true
@spawn(@getCmdPath(), cmdArgs, cmdOptions)

View File

@@ -91,4 +91,12 @@ function normalize (options = {}) {
}
}
export default { getFromShell, needsPatching, normalize }
function replace (env) {
if (!env || !env.PATH) {
return
}
process.env = env
}
export default { getFromShell, needsPatching, normalize, replace }

View File

@@ -40,7 +40,7 @@ export default class GitRepositoryAsync {
constructor (_path, options = {}) {
// We'll serialize our access manually.
Git.disableThreadSafety()
Git.setThreadSafetyStatus(Git.THREAD_SAFETY.DISABLED)
this.emitter = new Emitter()
this.subscriptions = new CompositeDisposable()
@@ -305,7 +305,7 @@ export default class GitRepositoryAsync {
.then(relativePath => {
return this.repoPool.enqueue(() => {
return this.getRepo()
.then(repo => repo.openIndex())
.then(repo => repo.index())
.then(index => {
const entry = index.getByPath(relativePath)
if (!entry) return false

View File

@@ -166,7 +166,12 @@ class GitRepository
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidChangeStatuses: (callback) ->
@async.onDidChangeStatuses callback
@async.onDidChangeStatuses ->
# Defer the callback to the next tick so that we've reset
# `@statusesByPath` by the time it's called. Otherwise reads from within
# the callback could be inconsistent.
# See https://github.com/atom/atom/issues/11396
process.nextTick callback
###
Section: Repository Details

View File

@@ -4,11 +4,12 @@ module.exports = ({blobStore}) ->
path = require 'path'
require './window'
{getWindowLoadSettings} = require './window-load-settings-helpers'
{ipcRenderer} = require 'electron'
{resourcePath, isSpec, devMode, env} = getWindowLoadSettings()
# Set baseline environment
environmentHelpers.normalize({env: env})
env = process.env
# Add application-specific exports to module search path.
exportsPath = path.join(resourcePath, 'exports')
@@ -25,7 +26,7 @@ module.exports = ({blobStore}) ->
applicationDelegate: new ApplicationDelegate,
configDirPath: process.env.ATOM_HOME
enablePersistence: true
env: env
env: process.env
})
atom.startEditorWindow().then ->
@@ -35,3 +36,6 @@ module.exports = ({blobStore}) ->
window.removeEventListener('focus', windowFocused)
setTimeout (-> document.querySelector('atom-workspace').focus()), 0
window.addEventListener('focus', windowFocused)
ipcRenderer.on('environment', (event, env) ->
environmentHelpers.replace(env)
)

View File

@@ -442,15 +442,16 @@ class Pane extends Model
if typeof item.onDidTerminatePendingState is "function"
itemSubscriptions.add item.onDidTerminatePendingState =>
@clearPendingItem() if @getPendingItem() is item
itemSubscriptions.add item.onDidDestroy => @removeItem(item, false)
@subscriptionsPerItem.set item, itemSubscriptions
@items.splice(index, 0, item)
lastPendingItem = @getPendingItem()
replacingPendingItem = lastPendingItem? and not moved
@pendingItem = null if replacingPendingItem
@setPendingItem(item) if pending
@emitter.emit 'did-add-item', {item, index, moved}
@destroyItem(lastPendingItem) if lastPendingItem? and not moved
@destroyItem(lastPendingItem) if replacingPendingItem
@setActiveItem(item) unless @getActiveItem()?
item
@@ -458,7 +459,8 @@ class Pane extends Model
if @pendingItem isnt item
mostRecentPendingItem = @pendingItem
@pendingItem = item
@emitter.emit 'item-did-terminate-pending-state', mostRecentPendingItem
if mostRecentPendingItem?
@emitter.emit 'item-did-terminate-pending-state', mostRecentPendingItem
getPendingItem: =>
@pendingItem or null

View File

@@ -247,9 +247,50 @@ class TextEditorComponent
@scrollViewNode.addEventListener 'mousedown', @onMouseDown
@scrollViewNode.addEventListener 'scroll', @onScrollViewScroll
@detectAccentedCharacterMenu()
@listenForIMEEvents()
@trackSelectionClipboard() if process.platform is 'linux'
detectAccentedCharacterMenu: ->
# We need to get clever to detect when the accented character menu is
# opened on OS X. Usually, every keydown event that could cause input is
# followed by a corresponding keypress. However, pressing and holding
# long enough to open the accented character menu causes additional keydown
# events to fire that aren't followed by their own keypress and textInput
# events.
#
# Therefore, we assume the accented character menu has been deployed if,
# before observing any keyup event, we observe events in the following
# sequence:
#
# keydown(keyCode: X), keypress, keydown(keyCode: X)
#
# The keyCode X must be the same in the keydown events that bracket the
# keypress, meaning we're *holding* the _same_ key we intially pressed.
# Got that?
lastKeydown = null
lastKeydownBeforeKeypress = null
@domNode.addEventListener 'keydown', (event) =>
if lastKeydownBeforeKeypress
if lastKeydownBeforeKeypress.keyCode is event.keyCode
@openedAccentedCharacterMenu = true
lastKeydownBeforeKeypress = null
else
lastKeydown = event
@domNode.addEventListener 'keypress', =>
lastKeydownBeforeKeypress = lastKeydown
lastKeydown = null
# This cancels the accented character behavior if we type a key normally
# with the menu open.
@openedAccentedCharacterMenu = false
@domNode.addEventListener 'keyup', ->
lastKeydownBeforeKeypress = null
lastKeydown = null
listenForIMEEvents: ->
# The IME composition events work like this:
#
@@ -266,6 +307,9 @@ class TextEditorComponent
checkpoint = null
@domNode.addEventListener 'compositionstart', =>
if @openedAccentedCharacterMenu
@editor.selectLeft()
@openedAccentedCharacterMenu = false
checkpoint = @editor.createCheckpoint()
@domNode.addEventListener 'compositionupdate', (event) =>
@editor.insertText(event.data, select: true)
@@ -321,24 +365,21 @@ class TextEditorComponent
onTextInput: (event) =>
event.stopPropagation()
# If we prevent the insertion of a space character, then the browser
# interprets the spacebar keypress as a page-down command.
event.preventDefault() unless event.data is ' '
event.preventDefault()
return unless @isInputEnabled()
inputNode = event.target
# Workaround of the accented character suggestion feature in OS X.
# This will only occur when the user is not composing in IME mode.
# When the user selects a modified character from the OSX menu, `textInput`
# will occur twice, once for the initial character, and once for the
# modified character. However, only a single keypress will have fired. If
# this is the case, select backward to replace the original character.
if @openedAccentedCharacterMenu
@editor.selectLeft()
@openedAccentedCharacterMenu = false
# Work around of the accented character suggestion feature in OS X.
# Text input fires before a character is inserted, and if the browser is
# replacing the previous un-accented character with an accented variant, it
# will select backward over it.
selectedLength = inputNode.selectionEnd - inputNode.selectionStart
@editor.selectLeft() if selectedLength is 1
insertedRange = @editor.insertText(event.data, groupUndo: true)
inputNode.value = event.data if insertedRange
@editor.insertText(event.data, groupUndo: true)
onVerticalScroll: (scrollTop) =>
return if @updateRequested or scrollTop is @presenter.getScrollTop()

View File

@@ -1551,7 +1551,7 @@ class TextEditor extends Model
#
# * `markerLayer` A {TextEditorMarkerLayer} or {MarkerLayer} to decorate.
# * `decorationParams` The same parameters that are passed to
# {decorateMarker}, except the `type` cannot be `overlay` or `gutter`.
# {TextEditor::decorateMarker}, except the `type` cannot be `overlay` or `gutter`.
#
# This API is experimental and subject to change on any release.
#