mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Merge pull request #10178 from atom/ku-pending-editor
Open file in pending state on single click
This commit is contained in:
@@ -337,13 +337,19 @@ class Pane extends Model
|
||||
#
|
||||
# * `index` {Number}
|
||||
activateItemAtIndex: (index) ->
|
||||
@activateItem(@itemAtIndex(index))
|
||||
item = @itemAtIndex(index) or @getActiveItem()
|
||||
@setActiveItem(item)
|
||||
|
||||
# Public: Make the given item *active*, causing it to be displayed by
|
||||
# the pane's view.
|
||||
activateItem: (item) ->
|
||||
if item?
|
||||
@addItem(item, @getActiveItemIndex() + 1, false)
|
||||
if @activeItem?.isPending?()
|
||||
index = @getActiveItemIndex()
|
||||
@destroyActiveItem() unless item is @activeItem
|
||||
else
|
||||
index = @getActiveItemIndex() + 1
|
||||
@addItem(item, index, false)
|
||||
@setActiveItem(item)
|
||||
|
||||
# Public: Add the given item to the pane.
|
||||
@@ -574,7 +580,6 @@ class Pane extends Model
|
||||
# Public: Makes this pane the *active* pane, causing it to gain focus.
|
||||
activate: ->
|
||||
throw new Error("Pane has been destroyed") if @isDestroyed()
|
||||
|
||||
@container?.setActivePane(this)
|
||||
@emitter.emit 'did-activate'
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class TextEditor extends Model
|
||||
softWrapped, @displayBuffer, @selectionsMarkerLayer, buffer, suppressCursorCreation,
|
||||
@mini, @placeholderText, lineNumberGutterVisible, largeFileMode, @config,
|
||||
@notificationManager, @packageManager, @clipboard, @viewRegistry, @grammarRegistry,
|
||||
@project, @assert, @applicationDelegate
|
||||
@project, @assert, @applicationDelegate, @pending
|
||||
} = params
|
||||
|
||||
throw new Error("Must pass a config parameter when constructing TextEditors") unless @config?
|
||||
@@ -161,6 +161,9 @@ class TextEditor extends Model
|
||||
@disposables.add @buffer.onDidChangeEncoding =>
|
||||
@emitter.emit 'did-change-encoding', @getEncoding()
|
||||
@disposables.add @buffer.onDidDestroy => @destroy()
|
||||
if @pending
|
||||
@disposables.add @buffer.onDidChangeModified =>
|
||||
@terminatePendingState() if @buffer.isModified()
|
||||
|
||||
@preserveCursorPositionOnBufferReload()
|
||||
|
||||
@@ -569,6 +572,13 @@ class TextEditor extends Model
|
||||
getEditorWidthInChars: ->
|
||||
@displayBuffer.getEditorWidthInChars()
|
||||
|
||||
onDidTerminatePendingState: (callback) ->
|
||||
@emitter.on 'did-terminate-pending-state', callback
|
||||
|
||||
terminatePendingState: ->
|
||||
@pending = false
|
||||
@emitter.emit 'did-terminate-pending-state', this
|
||||
|
||||
###
|
||||
Section: File Details
|
||||
###
|
||||
@@ -652,6 +662,9 @@ class TextEditor extends Model
|
||||
# Essential: Returns {Boolean} `true` if this editor has no content.
|
||||
isEmpty: -> @buffer.isEmpty()
|
||||
|
||||
# Returns {Boolean} `true` if this editor is pending and `false` if it is permanent.
|
||||
isPending: -> Boolean(@pending)
|
||||
|
||||
# Copies the current file path to the native clipboard.
|
||||
copyPathToClipboard: ->
|
||||
if filePath = @getPath()
|
||||
|
||||
Reference in New Issue
Block a user