mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add function that only copies selected text unless the cursor is at the beginning of the line.
This commit is contained in:
@@ -302,6 +302,7 @@ atom.commands.add 'atom-text-editor', stopEventPropagationAndGroupUndo(
|
||||
'editor:transpose': -> @transpose()
|
||||
'editor:upper-case': -> @upperCase()
|
||||
'editor:lower-case': -> @lowerCase()
|
||||
'editor:copy-selection': -> @copyOnlySelectedText()
|
||||
)
|
||||
|
||||
atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagation(
|
||||
|
||||
@@ -2587,6 +2587,18 @@ class TextEditor extends Model
|
||||
maintainClipboard = true
|
||||
return
|
||||
|
||||
|
||||
# Essential: For each selection, only copy hightlighted text. Line is coptied if no selected text and cursor is at the beginning of the line
|
||||
copyOnlySelectedText: ->
|
||||
maintainClipboard = false
|
||||
for selection in @getSelectionsOrderedByBufferPosition()
|
||||
if not selection.isEmpty()
|
||||
selection.copy(maintainClipboard, true)
|
||||
else if selection.isEmpty() and selection.cursor.isAtBeginningOfLine()
|
||||
@copySelectedText()
|
||||
maintainClipboard = true
|
||||
return
|
||||
|
||||
# Essential: For each selection, cut the selected text.
|
||||
cutSelectedText: ->
|
||||
maintainClipboard = false
|
||||
|
||||
Reference in New Issue
Block a user