diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 1435aef19..f769646dc 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -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()