mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Update editor component when a visible selection is removed
This commit is contained in:
@@ -53,8 +53,8 @@ describe "EditorComponent", ->
|
||||
expect(cursorNodes[0].offsetTop).toBe 0
|
||||
expect(cursorNodes[0].offsetLeft).toBe 5 * charWidth
|
||||
|
||||
cursor3 = editor.addCursorAtScreenPosition([6, 11])
|
||||
cursor2 = editor.addCursorAtScreenPosition([4, 10])
|
||||
cursor2 = editor.addCursorAtScreenPosition([6, 11])
|
||||
cursor3 = editor.addCursorAtScreenPosition([4, 10])
|
||||
|
||||
cursorNodes = node.querySelectorAll('.cursor')
|
||||
expect(cursorNodes.length).toBe 2
|
||||
@@ -72,3 +72,9 @@ describe "EditorComponent", ->
|
||||
expect(cursorNodes[0].offsetLeft).toBe 11 * charWidth
|
||||
expect(cursorNodes[1].offsetTop).toBe 4 * lineHeight
|
||||
expect(cursorNodes[1].offsetLeft).toBe 10 * charWidth
|
||||
|
||||
cursor3.destroy()
|
||||
cursorNodes = node.querySelectorAll('.cursor')
|
||||
expect(cursorNodes.length).toBe 1
|
||||
expect(cursorNodes[0].offsetTop).toBe 6 * lineHeight
|
||||
expect(cursorNodes[0].offsetLeft).toBe 11 * charWidth
|
||||
|
||||
@@ -65,6 +65,7 @@ EditorCompont = React.createClass
|
||||
{editor} = @props
|
||||
@subscribe editor, 'screen-lines-changed', @onScreenLinesChanged
|
||||
@subscribe editor, 'selection-added', @onSelectionAdded
|
||||
@subscribe editor, 'selection-removed', @onSelectionAdded
|
||||
|
||||
@updateAllDimensions()
|
||||
@props.editor.setVisible(true)
|
||||
@@ -104,6 +105,9 @@ EditorCompont = React.createClass
|
||||
onSelectionAdded: (selection) ->
|
||||
@forceUpdate() if @selectionIntersectsVisibleRowRange(selection)
|
||||
|
||||
onSelectionRemoved: (selection) ->
|
||||
@forceUpdate() if @selectionIntersectsVisibleRowRange(selection)
|
||||
|
||||
getVisibleRowRange: ->
|
||||
return [0, 0] unless @state.lineHeight > 0
|
||||
|
||||
|
||||
@@ -1202,6 +1202,7 @@ class Editor extends Model
|
||||
# Remove the given selection.
|
||||
removeSelection: (selection) ->
|
||||
_.remove(@selections, selection)
|
||||
@emit 'selection-removed', selection
|
||||
|
||||
# Reduce one or more selections to a single empty selection based on the most
|
||||
# recently added cursor.
|
||||
|
||||
Reference in New Issue
Block a user