mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Alt-meta-f folds the current selection
This commit is contained in:
parent
0bdc45037f
commit
dfcf4a1629
@ -733,3 +733,10 @@ describe "Editor", ->
|
||||
editor.trigger "paste"
|
||||
expect(editor.buffer.getLine(1)).toBe " var first = function(items) {"
|
||||
|
||||
describe "folding", ->
|
||||
describe "when a fold-selection event is triggered", ->
|
||||
it "folds the selected text and renders a placeholder for it", ->
|
||||
editor.selection.setRange(new Range([4, 29], [7, 4]))
|
||||
editor.trigger 'fold-selection'
|
||||
expect(editor.lines.find('.line:eq(4)').text()).toBe ' while(items.length > 0) {...}'
|
||||
|
||||
|
@ -58,6 +58,7 @@ class Editor extends View
|
||||
'meta-z': 'undo'
|
||||
'meta-Z': 'redo'
|
||||
'alt-meta-w': 'toggle-soft-wrap'
|
||||
'alt-meta-f': 'fold-selection'
|
||||
|
||||
@on 'move-right', => @moveCursorRight()
|
||||
@on 'move-left', => @moveCursorLeft()
|
||||
@ -76,6 +77,7 @@ class Editor extends View
|
||||
@on 'undo', => @undo()
|
||||
@on 'redo', => @redo()
|
||||
@on 'toggle-soft-wrap', => @toggleSoftWrap()
|
||||
@on 'fold-selection', => @foldSelection()
|
||||
|
||||
buildCursorAndSelection: ->
|
||||
@cursor = new Cursor(this)
|
||||
@ -273,6 +275,8 @@ class Editor extends View
|
||||
copySelection: -> @selection.copy()
|
||||
paste: -> @selection.insertText(atom.native.readFromPasteboard())
|
||||
|
||||
foldSelection: -> @selection.fold()
|
||||
|
||||
backspace: ->
|
||||
@selectLeft() if @selection.isEmpty()
|
||||
@selection.delete()
|
||||
|
@ -1,4 +1,5 @@
|
||||
Cursor = require 'cursor'
|
||||
|
||||
Range = require 'range'
|
||||
{View, $$} = require 'space-pen'
|
||||
|
||||
@ -157,3 +158,6 @@ class Selection extends View
|
||||
return if @isEmpty()
|
||||
text = @editor.buffer.getTextInRange @getRange()
|
||||
atom.native.writeToPasteboard text
|
||||
|
||||
fold: ->
|
||||
@editor.lineFolder.createFold(@getRange())
|
||||
|
Loading…
Reference in New Issue
Block a user