Lowercase current word/selection with meta-U

This commit is contained in:
Kevin Sawicki
2013-01-07 09:35:52 -08:00
parent 2a0ee62685
commit bbdff31faf
4 changed files with 35 additions and 8 deletions

View File

@@ -314,6 +314,17 @@ class EditSession
mutateSelectedText: (fn) ->
@transact => fn(selection) for selection in @getSelections()
replaceSelectedText: (options={}, fn) ->
{selectWordIfEmpty} = options
@mutateSelectedText (selection) =>
range = selection.getBufferRange()
if selectWordIfEmpty and selection.isEmpty()
selection.selectWord()
text = selection.getText()
selection.delete()
selection.insertText(fn(text))
selection.setBufferRange(range)
pushOperation: (operation) ->
@buffer.pushOperation(operation, this)
@@ -553,14 +564,10 @@ class EditSession
selection.insertText selection.getText().split('').reverse().join('')
upperCase: ->
@mutateSelectedText (selection) =>
range = selection.getBufferRange()
if selection.isEmpty()
selection.selectWord()
text = selection.getText()
selection.delete()
selection.insertText text.toUpperCase()
selection.setBufferRange(range) if range
@replaceSelectedText selectWordIfEmpty:true, (text) => text.toUpperCase()
lowerCase: ->
@replaceSelectedText selectWordIfEmpty:true, (text) => text.toLowerCase()
expandLastSelectionOverLine: ->
@getLastSelection().expandOverLine()