mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Fix regression: folds can be destroyed by clicking them
This commit is contained in:
@@ -1943,9 +1943,11 @@ describe "Editor", ->
|
||||
describe "when a fold placeholder line is clicked", ->
|
||||
it "removes the associated fold and places the cursor at its beginning", ->
|
||||
editor.setCursorBufferPosition([3,0])
|
||||
editor.trigger 'editor:fold-current-row'
|
||||
editSession.createFold(3, 5)
|
||||
|
||||
editor.find('.fold.line').mousedown()
|
||||
foldLine = editor.find('.line.fold')
|
||||
expect(foldLine).toExist()
|
||||
foldLine.mousedown()
|
||||
|
||||
expect(editor.find('.fold')).not.toExist()
|
||||
expect(editor.find('.fold-marker')).not.toExist()
|
||||
|
||||
@@ -107,6 +107,10 @@ class DisplayBuffer
|
||||
@buffer.markRange([[startRow, 0], [endRow, Infinity]], @foldMarkerAttributes())
|
||||
@foldForMarker(foldMarker)
|
||||
|
||||
# Destroys the fold with the given id
|
||||
destroyFoldWithId: (id) ->
|
||||
@foldsByMarkerId[id]?.destroy()
|
||||
|
||||
# Removes any folds found that contain the given buffer row.
|
||||
#
|
||||
# bufferRow - The buffer row {Number} to check against
|
||||
|
||||
@@ -540,6 +540,10 @@ class EditSession
|
||||
createFold: (startRow, endRow) ->
|
||||
@displayBuffer.createFold(startRow, endRow)
|
||||
|
||||
# {Delegates to: DisplayBuffer.destroyFoldWithId}
|
||||
destroyFoldWithId: (id) ->
|
||||
@displayBuffer.destroyFoldWithId(id)
|
||||
|
||||
# {Delegates to: DisplayBuffer.destroyFoldsContainingBufferRow}
|
||||
destroyFoldsContainingBufferRow: (bufferRow) ->
|
||||
@displayBuffer.destroyFoldsContainingBufferRow(bufferRow)
|
||||
|
||||
@@ -621,7 +621,7 @@ class Editor extends View
|
||||
false if @isFocused
|
||||
|
||||
@renderedLines.on 'mousedown', '.fold.line', (e) =>
|
||||
@destroyFold($(e.currentTarget).attr('fold-id'))
|
||||
@activeEditSession.destroyFoldWithId($(e.currentTarget).attr('fold-id'))
|
||||
false
|
||||
|
||||
@renderedLines.on 'mousedown', (e) =>
|
||||
|
||||
@@ -7,12 +7,14 @@ Point = require 'point'
|
||||
# Their creation is managed by the {DisplayBuffer}.
|
||||
module.exports =
|
||||
class Fold
|
||||
id: null
|
||||
displayBuffer: null
|
||||
marker: null
|
||||
|
||||
### Internal ###
|
||||
|
||||
constructor: (@displayBuffer, @marker) ->
|
||||
@id = @marker.id
|
||||
@displayBuffer.foldsByMarkerId[@marker.id] = this
|
||||
@updateDisplayBuffer()
|
||||
@marker.on 'destroyed', => @destroyed()
|
||||
|
||||
Reference in New Issue
Block a user