mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Add indentBasis metadata to pasteboard when copying text
This allows indent to be normalized properly even if the leading whitespace isn't copied from the first line.
This commit is contained in:
@@ -202,7 +202,8 @@ class EditSession
|
||||
maintainPasteboard = true
|
||||
|
||||
pasteText: ->
|
||||
@insertText(pasteboard.read()[0], normalizeIndent: true)
|
||||
[text, metadata] = pasteboard.read()
|
||||
@insertText(text, _.extend(metadata ? {}, normalizeIndent: true))
|
||||
|
||||
undo: ->
|
||||
@buffer.undo(this)
|
||||
|
||||
@@ -269,8 +269,13 @@ class Selection
|
||||
copy: (maintainPasteboard=false) ->
|
||||
return if @isEmpty()
|
||||
text = @editSession.buffer.getTextInRange(@getBufferRange())
|
||||
text = pasteboard.read()[0] + "\n" + text if maintainPasteboard
|
||||
pasteboard.write(text)
|
||||
if maintainPasteboard
|
||||
[currentText, metadata] = pasteboard.read()
|
||||
text = currentText + '\n' + text
|
||||
else
|
||||
metadata = { indentBasis: @editSession.indentationForBufferRow(@getBufferRange().start.row) }
|
||||
|
||||
pasteboard.write(text, metadata)
|
||||
|
||||
fold: ->
|
||||
range = @getBufferRange()
|
||||
|
||||
Reference in New Issue
Block a user