mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Terminate drag on any buffer change
Not just text insertion.
This commit is contained in:
@@ -1898,16 +1898,13 @@ describe "TextEditorComponent", ->
|
||||
expect(nextAnimationFrame).toBe noAnimationFrame
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [6, 8]]
|
||||
|
||||
it "stops selecting if a textInput event occurs during the drag", ->
|
||||
it "stops selecting before the buffer is modified during the drag", ->
|
||||
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([2, 4]), which: 1))
|
||||
linesNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenPosition([6, 8]), which: 1))
|
||||
nextAnimationFrame()
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [6, 8]]
|
||||
|
||||
inputEvent = new Event('textInput')
|
||||
inputEvent.data = 'x'
|
||||
Object.defineProperty(inputEvent, 'target', get: -> componentNode.querySelector('.hidden-input'))
|
||||
componentNode.dispatchEvent(inputEvent)
|
||||
editor.insertText('x')
|
||||
nextAnimationFrame()
|
||||
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 5], [2, 5]]
|
||||
@@ -1916,6 +1913,20 @@ describe "TextEditorComponent", ->
|
||||
expect(nextAnimationFrame).toBe noAnimationFrame
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 5], [2, 5]]
|
||||
|
||||
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([2, 4]), which: 1))
|
||||
linesNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenPosition([5, 4]), which: 1))
|
||||
nextAnimationFrame()
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [5, 4]]
|
||||
|
||||
editor.delete()
|
||||
nextAnimationFrame()
|
||||
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [2, 4]]
|
||||
|
||||
linesNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenPosition([8, 0]), which: 1))
|
||||
expect(nextAnimationFrame).toBe noAnimationFrame
|
||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [2, 4]]
|
||||
|
||||
describe "when the command key is held down", ->
|
||||
it "adds a new selection and selects to the nearest screen position, then merges intersecting selections when the mouse button is released", ->
|
||||
editor.setSelectedScreenRange([[4, 4], [4, 9]])
|
||||
|
||||
@@ -578,7 +578,7 @@ class TextEditorComponent
|
||||
window.addEventListener('mousemove', onMouseMove)
|
||||
window.addEventListener('mouseup', onMouseUp)
|
||||
disposables = new CompositeDisposable
|
||||
disposables.add(@editor.onWillInsertText(onMouseUp))
|
||||
disposables.add(@editor.getBuffer().onWillChange(onMouseUp))
|
||||
disposables.add(@editor.onDidDestroy(stopDragging))
|
||||
|
||||
isVisible: ->
|
||||
|
||||
Reference in New Issue
Block a user