mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Workspace#setItemNotPending ➡️ Item#onDidTerminatePendingState
Signed-off-by: Michelle Tilley <binarymuse@github.com>
This commit is contained in:
committed by
Michelle Tilley
parent
d0ffbca845
commit
b637366a58
@@ -1,5 +1,5 @@
|
||||
{find, compact, extend, last} = require 'underscore-plus'
|
||||
{Emitter} = require 'event-kit'
|
||||
{CompositeDisposable, Emitter} = require 'event-kit'
|
||||
Model = require './model'
|
||||
PaneAxis = require './pane-axis'
|
||||
TextEditor = require './text-editor'
|
||||
@@ -42,7 +42,7 @@ class Pane extends Model
|
||||
} = params
|
||||
|
||||
@emitter = new Emitter
|
||||
@itemSubscriptions = new WeakMap
|
||||
@subscriptionsPerItem = new WeakMap
|
||||
@items = []
|
||||
|
||||
@addItems(compact(params?.items ? []))
|
||||
@@ -265,8 +265,8 @@ class Pane extends Model
|
||||
getPanes: -> [this]
|
||||
|
||||
unsubscribeFromItem: (item) ->
|
||||
@itemSubscriptions.get(item)?.dispose()
|
||||
@itemSubscriptions.delete(item)
|
||||
@subscriptionsPerItem.get(item)?.dispose()
|
||||
@subscriptionsPerItem.delete(item)
|
||||
|
||||
###
|
||||
Section: Items
|
||||
@@ -378,7 +378,13 @@ class Pane extends Model
|
||||
@setPendingItem(item) if pending
|
||||
|
||||
if typeof item.onDidDestroy is 'function'
|
||||
@itemSubscriptions.set item, item.onDidDestroy => @removeItem(item, false)
|
||||
itemSubscriptions = new CompositeDisposable
|
||||
itemSubscriptions.add item.onDidDestroy => @removeItem(item, false)
|
||||
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)
|
||||
@emitter.emit 'did-add-item', {item, index, moved}
|
||||
|
||||
@@ -165,11 +165,13 @@ class TextEditor extends Model
|
||||
@emitter.emit 'did-change-encoding', @getEncoding()
|
||||
@disposables.add @buffer.onDidDestroy => @destroy()
|
||||
@disposables.add @buffer.onDidChangeModified =>
|
||||
atom.workspace.setItemNotPending(this) if not @bufferHasChanged and @buffer.isModified()
|
||||
@bufferHasChanged = true
|
||||
@emitter.emit 'did-terminate-pending-state'
|
||||
|
||||
@preserveCursorPositionOnBufferReload()
|
||||
|
||||
onDidTerminatePendingState: (callback) ->
|
||||
@emitter.on 'did-terminate-pending-state', callback
|
||||
|
||||
subscribeToDisplayBuffer: ->
|
||||
@disposables.add @selectionsMarkerLayer.onDidCreateMarker @addSelection.bind(this)
|
||||
@disposables.add @displayBuffer.onDidChangeGrammar @handleGrammarChange.bind(this)
|
||||
|
||||
@@ -515,12 +515,6 @@ class Workspace extends Model
|
||||
@emitter.emit 'did-open', {uri, pane, item, index}
|
||||
item
|
||||
|
||||
setItemNotPending: (item) =>
|
||||
for pane in @getPanes()
|
||||
if item is pane.getPendingItem()
|
||||
pane.setPendingItem(null)
|
||||
break
|
||||
|
||||
openTextFile: (uri, options) ->
|
||||
filePath = @project.resolvePath(uri)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user