Implement editor:move-selection-left

This commit is contained in:
Machiste Quintana
2015-05-03 20:25:47 -04:00
parent 7f7ca75113
commit 1f023d1d2c
4 changed files with 31 additions and 1 deletions

View File

@@ -127,6 +127,8 @@
# Atom Specific
'ctrl-W': 'editor:select-word'
'cmd-ctrl-left': 'editor:move-selection-left'
'cmd-ctrl-right': 'editor:move-selection-right'
# Sublime Parity
'cmd-a': 'core:select-all'

View File

@@ -74,6 +74,13 @@
{ label: 'Join Lines', command: 'editor:join-lines' }
]
}
{
label: 'Columns',
submenu: [
{ label: 'Move Selection Left', command: 'editor:move-selection-left' }
{ label: 'Move Selection Right', command: 'editor:move-selection-right' }
]
}
{
label: 'Text',
submenu: [
@@ -128,7 +135,6 @@
{ label: 'Select to First Character of Line', command: 'editor:select-to-first-character-of-line' }
{ label: 'Select to End of Word', command: 'editor:select-to-end-of-word' }
{ label: 'Select to End of Line', command: 'editor:select-to-end-of-line' }
{ label: 'Move Selection Right', command: 'editor:move-selection-right' }
]
}

View File

@@ -343,6 +343,7 @@ atom.commands.add 'atom-text-editor:not([mini])', stopEventPropagationAndGroupUn
'editor:checkout-head-revision': -> @checkoutHeadRevision()
'editor:move-line-up': -> @moveLineUp()
'editor:move-line-down': -> @moveLineDown()
'editor:move-selection-left': -> @moveSelectionLeft()
'editor:move-selection-right': -> @moveSelectionRight()
'editor:duplicate-lines': -> @duplicateLines()
'editor:join-lines': -> @joinLines()

View File

@@ -932,6 +932,27 @@ class TextEditor extends Model
@setSelectedBufferRange(selection.translate([insertDelta]), preserveFolds: true, autoscroll: true)
moveSelectionLeft: ->
selections = @getSelectedBufferRanges()
translationDelta = [0, -1]
translatedRanges = []
@transact =>
for selection in selections
range = new Range(selection.start.translate(translationDelta), selection.start)
insertionPoint = selection.end
text = @buffer.getTextInRange(range)
console.log(text)
@buffer.insert(insertionPoint, text)
@buffer.delete(range)
translatedRanges.push(selection.translate(translationDelta))
@setSelectedBufferRanges(translatedRanges)
moveSelectionRight: ->
selections = @getSelectedBufferRanges()