mirror of
https://github.com/atom/atom.git
synced 2026-02-15 17:15:24 -05:00
Implements multiple selections clipboard paste
Includes: - Passing the selection index in the `Editor::mutateSelectedText` method callback - Storing all the selections content on many calls of `Selection::copy` with `maintainClipboard = true` in a metadata `selections` array - Handling clipboard with a `selections` metadata in the`Editor::pasteText` method
This commit is contained in:
@@ -503,11 +503,24 @@ class Selection extends Model
|
||||
@delete()
|
||||
|
||||
# Public: Copies the current selection to the clipboard.
|
||||
#
|
||||
# If the `maintainClipboard` is set to `true`, a specific metadata property
|
||||
# is created to store each content copied to the clipboard. The clipboard
|
||||
# `text` still contains the concatenation of the clipboard with the
|
||||
# current selection.
|
||||
copy: (maintainClipboard=false) ->
|
||||
return if @isEmpty()
|
||||
text = @editor.buffer.getTextInRange(@getBufferRange())
|
||||
if maintainClipboard
|
||||
text = "#{atom.clipboard.read()}\n#{text}"
|
||||
{text: clipboardText, metadata: clipboardMetadata} = atom.clipboard.readWithMetadata()
|
||||
|
||||
if clipboardMetadata? and clipboardMetadata.selections?
|
||||
metadata = clipboardMetadata
|
||||
clipboardMetadata.selections.push(text)
|
||||
else
|
||||
metadata = { selections: [clipboardText, text] }
|
||||
|
||||
text = "" + (clipboardText) + "\n" + text
|
||||
else
|
||||
metadata = { indentBasis: @editor.indentationForBufferRow(@getBufferRange().start.row) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user