mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Merge branch 'master' into ns-alternative-test-env
This commit is contained in:
@@ -146,6 +146,8 @@ class AtomWindow
|
||||
when 0 then @browserWindow.destroy()
|
||||
when 1 then @browserWindow.restart()
|
||||
|
||||
@browserWindow.webContents.on 'will-navigate', (event) -> event.preventDefault()
|
||||
|
||||
@setupContextMenu()
|
||||
|
||||
if @isSpec
|
||||
|
||||
@@ -9,6 +9,8 @@ module.exports =
|
||||
class PaneContainer extends Model
|
||||
serializationVersion: 1
|
||||
root: null
|
||||
stoppedChangingActivePaneItemDelay: 100
|
||||
stoppedChangingActivePaneItemTimeout: null
|
||||
|
||||
constructor: (params) ->
|
||||
super
|
||||
@@ -73,6 +75,9 @@ class PaneContainer extends Model
|
||||
onDidChangeActivePaneItem: (fn) ->
|
||||
@emitter.on 'did-change-active-pane-item', fn
|
||||
|
||||
onDidStopChangingActivePaneItem: (fn) ->
|
||||
@emitter.on 'did-stop-changing-active-pane-item', fn
|
||||
|
||||
observeActivePaneItem: (fn) ->
|
||||
fn(@getActivePaneItem())
|
||||
@onDidChangeActivePaneItem(fn)
|
||||
@@ -180,12 +185,18 @@ class PaneContainer extends Model
|
||||
|
||||
# Called by Model superclass when destroyed
|
||||
destroyed: ->
|
||||
@cancelStoppedChangingActivePaneItemTimeout()
|
||||
pane.destroy() for pane in @getPanes()
|
||||
@subscriptions.dispose()
|
||||
@emitter.dispose()
|
||||
|
||||
cancelStoppedChangingActivePaneItemTimeout: ->
|
||||
if @stoppedChangingActivePaneItemTimeout?
|
||||
clearTimeout(@stoppedChangingActivePaneItemTimeout)
|
||||
|
||||
monitorActivePaneItem: ->
|
||||
childSubscription = null
|
||||
|
||||
@subscriptions.add @observeActivePane (activePane) =>
|
||||
if childSubscription?
|
||||
@subscriptions.remove(childSubscription)
|
||||
@@ -193,6 +204,14 @@ class PaneContainer extends Model
|
||||
|
||||
childSubscription = activePane.observeActiveItem (activeItem) =>
|
||||
@emitter.emit 'did-change-active-pane-item', activeItem
|
||||
@cancelStoppedChangingActivePaneItemTimeout()
|
||||
stoppedChangingActivePaneItemCallback = =>
|
||||
@stoppedChangingActivePaneItemTimeout = null
|
||||
@emitter.emit 'did-stop-changing-active-pane-item', activeItem
|
||||
@stoppedChangingActivePaneItemTimeout =
|
||||
setTimeout(
|
||||
stoppedChangingActivePaneItemCallback,
|
||||
@stoppedChangingActivePaneItemDelay)
|
||||
|
||||
@subscriptions.add(childSubscription)
|
||||
|
||||
|
||||
@@ -205,11 +205,34 @@ class Workspace extends Model
|
||||
|
||||
# Essential: Invoke the given callback when the active pane item changes.
|
||||
#
|
||||
# Because observers are invoked synchronously, it's important not to perform
|
||||
# any expensive operations via this method. Consider
|
||||
# {::onDidStopChangingActivePaneItem} to delay operations until after changes
|
||||
# stop occurring.
|
||||
#
|
||||
# * `callback` {Function} to be called when the active pane item changes.
|
||||
# * `item` The active pane item.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidChangeActivePaneItem: (callback) -> @paneContainer.onDidChangeActivePaneItem(callback)
|
||||
onDidChangeActivePaneItem: (callback) ->
|
||||
@paneContainer.onDidChangeActivePaneItem(callback)
|
||||
|
||||
# Essential: Invoke the given callback when the active pane item stops
|
||||
# changing.
|
||||
#
|
||||
# Observers are called asynchronously 100ms after the last active pane item
|
||||
# change. Handling changes here rather than in the synchronous
|
||||
# {::onDidChangeActivePaneItem} prevents unneeded work if the user is quickly
|
||||
# changing or closing tabs and ensures critical UI feedback, like changing the
|
||||
# highlighted tab, gets priority over work that can be done asynchronously.
|
||||
#
|
||||
# * `callback` {Function} to be called when the active pane item stopts
|
||||
# changing.
|
||||
# * `item` The active pane item.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidStopChangingActivePaneItem: (callback) ->
|
||||
@paneContainer.onDidStopChangingActivePaneItem(callback)
|
||||
|
||||
# Essential: Invoke the given callback with the current active pane item and
|
||||
# with all future active pane items in the workspace.
|
||||
|
||||
Reference in New Issue
Block a user