mirror of
https://github.com/atom/atom.git
synced 2026-02-03 11:14:59 -05:00
Add pending status to text editors
Add event methods for 'did-confirm-pending-state'.
This commit is contained in:
@@ -92,9 +92,10 @@ 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?
|
||||
throw new Error("Must pass a notificationManager parameter when constructing TextEditors") unless @notificationManager?
|
||||
throw new Error("Must pass a packageManager parameter when constructing TextEditors") unless @packageManager?
|
||||
@@ -161,6 +162,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 =>
|
||||
@confirmPendingState() if @buffer.isModified()
|
||||
|
||||
@preserveCursorPositionOnBufferReload()
|
||||
|
||||
@@ -569,6 +573,13 @@ class TextEditor extends Model
|
||||
getEditorWidthInChars: ->
|
||||
@displayBuffer.getEditorWidthInChars()
|
||||
|
||||
onDidConfirmPendingState: (callback) ->
|
||||
@emitter.on 'did-confirm-pending-state', callback
|
||||
|
||||
confirmPendingState: ->
|
||||
@pending = false
|
||||
@emitter.emit 'did-confirm-pending-state', this
|
||||
|
||||
###
|
||||
Section: File Details
|
||||
###
|
||||
@@ -652,6 +663,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