diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 97bcbf04b..2c8320383 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -91,7 +91,8 @@ beforeEach -> config: atom.config, project: atom.project, packageManager: atom.packages, grammarRegistry: atom.grammars, notificationManager: atom.notifications, setRepresentedFilename: jasmine.createSpy('setRepresentedFilename'), - setDocumentEdited: atom.setDocumentEdited.bind(atom), atomVersion: atom.getVersion() + setDocumentEdited: atom.setDocumentEdited.bind(atom), atomVersion: atom.getVersion(), + clipboard: atom.clipboard }) atom.themes.workspace = atom.workspace atom.keymaps.keyBindings = _.clone(keyBindingsToRestore) diff --git a/src/atom.coffee b/src/atom.coffee index 3ccff0fd5..6e46497f4 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -175,7 +175,7 @@ class Atom extends Model @workspace = new Workspace({ @config, @project, packageManager: @packages, grammarRegistry: @grammars, notificationManager: @notifications, setRepresentedFilename: @setRepresentedFilename.bind(this), - setDocumentEdited: @setDocumentEdited.bind(this) + setDocumentEdited: @setDocumentEdited.bind(this), @clipboard }) @themes.workspace = @workspace diff --git a/src/text-editor.coffee b/src/text-editor.coffee index c986408c5..4859c64d4 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -76,6 +76,7 @@ class TextEditor extends Model state.displayBuffer = displayBuffer state.config = atomEnvironment.config state.notificationManager = atomEnvironment.notifications + state.clipboard = atomEnvironment.clipboard new this(state) constructor: (params={}) -> @@ -84,7 +85,7 @@ class TextEditor extends Model { @softTabs, @scrollRow, @scrollColumn, initialLine, initialColumn, tabLength, softWrapped, @displayBuffer, buffer, suppressCursorCreation, @mini, @placeholderText, - lineNumberGutterVisible, largeFileMode, @config, @notificationManager + lineNumberGutterVisible, largeFileMode, @config, @notificationManager, @clipboard } = params @emitter = new Emitter @@ -460,7 +461,7 @@ class TextEditor extends Model softTabs = @getSoftTabs() newEditor = new TextEditor({ @buffer, displayBuffer, @tabLength, softTabs, suppressCursorCreation: true, - @config, @notificationManager + @config, @notificationManager, @clipboard }) for marker in @findMarkers(editorId: @id) marker.copy(editorId: newEditor.id, preserveFolds: true) @@ -590,7 +591,7 @@ class TextEditor extends Model # Copies the current file path to the native clipboard. copyPathToClipboard: -> if filePath = @getPath() - atom.clipboard.write(filePath) + @clipboard.write(filePath) ### Section: File Operations @@ -2618,7 +2619,7 @@ class TextEditor extends Model # # * `options` (optional) See {Selection::insertText}. pasteText: (options={}) -> - {text: clipboardText, metadata} = atom.clipboard.readWithMetadata() + {text: clipboardText, metadata} = @clipboard.readWithMetadata() return false unless @emitWillInsertTextEvent(clipboardText) metadata ?= {} diff --git a/src/workspace.coffee b/src/workspace.coffee index 6ad73b607..396bb9445 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -26,7 +26,7 @@ class Workspace extends Model constructor: (params) -> super - {@packageManager, @config, @project, @grammarRegistry, @notificationManager} = params + {@packageManager, @config, @project, @grammarRegistry, @notificationManager, @clipboard} = params {@setRepresentedFilename, @setDocumentEdited} = params @emitter = new Emitter @@ -456,7 +456,7 @@ class Workspace extends Model @buildTextEditor(_.extend({buffer, largeFileMode}, options)) buildTextEditor: (params) -> - new TextEditor(_.extend({@config, @notificationManager}, params)) + new TextEditor(_.extend({@config, @notificationManager, @clipboard}, params)) # Public: Asynchronously reopens the last-closed item's URI if it hasn't already been # reopened.