mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Toggle folding upon 'mousedown' on a foldable line's fold-icon
This commit is contained in:
@@ -715,6 +715,14 @@ describe "EditorView", ->
|
||||
expect(selection1.getScreenRange()).toEqual [[4, 10], [5, 27]]
|
||||
expect(selection2.getScreenRange()).toEqual [[6, 10], [8, 27]]
|
||||
|
||||
describe "mousedown on the fold icon of a foldable line number", ->
|
||||
it "toggles folding on the clicked buffer row", ->
|
||||
expect(editor.isFoldedAtScreenRow(1)).toBe false
|
||||
editorView.gutter.find('.line-number:eq(1) .fold-icon').mousedown()
|
||||
expect(editor.isFoldedAtScreenRow(1)).toBe true
|
||||
editorView.gutter.find('.line-number:eq(1) .fold-icon').mousedown()
|
||||
expect(editor.isFoldedAtScreenRow(1)).toBe false
|
||||
|
||||
describe "when text input events are triggered on the hidden input element", ->
|
||||
it "inserts the typed character at the cursor position, both in the buffer and the pre element", ->
|
||||
editorView.attachToDom()
|
||||
|
||||
@@ -348,6 +348,11 @@ class EditorView extends View
|
||||
@editor.destroyFoldWithId(id)
|
||||
false
|
||||
|
||||
@gutter.on 'mousedown', '.foldable .fold-icon', (e) =>
|
||||
bufferRow = $(e.target).parent().data('bufferRow')
|
||||
@editor.toggleFoldAtBufferRow(bufferRow)
|
||||
return false
|
||||
|
||||
@renderedLines.on 'mousedown', (e) =>
|
||||
clickCount = e.originalEvent.detail
|
||||
|
||||
|
||||
@@ -598,6 +598,14 @@ class Editor extends Model
|
||||
for row in [bufferRange.start.row..bufferRange.end.row]
|
||||
@destroyFoldsContainingBufferRow(row)
|
||||
|
||||
# Public: Folds the given buffer row if it's not currently folded, and unfolds
|
||||
# it otherwise.
|
||||
toggleFoldAtBufferRow: (bufferRow) ->
|
||||
if @isFoldedAtBufferRow(bufferRow)
|
||||
@unfoldBufferRow(bufferRow)
|
||||
else
|
||||
@foldBufferRow(bufferRow)
|
||||
|
||||
# Public: Returns whether the current row is folded.
|
||||
isFoldedAtCursorRow: ->
|
||||
@isFoldedAtScreenRow(@getCursorScreenRow())
|
||||
|
||||
Reference in New Issue
Block a user