mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #15916 from atom/as-jr-stop-dragging-when-interacting-with-keyboard
Stop dragging only when user interacts with keyboard
This commit is contained in:
@@ -1638,6 +1638,11 @@ class TextEditorComponent {
|
||||
// keypress, meaning we're *holding* the _same_ key we intially pressed.
|
||||
// Got that?
|
||||
didKeydown (event) {
|
||||
// Stop dragging when user interacts with the keyboard. This prevents
|
||||
// unwanted selections in the case edits are performed while selecting text
|
||||
// at the same time.
|
||||
if (this.stopDragging) this.stopDragging()
|
||||
|
||||
if (this.lastKeydownBeforeKeypress != null) {
|
||||
if (this.lastKeydownBeforeKeypress.code === event.code) {
|
||||
this.accentedCharacterMenuIsOpen = true
|
||||
@@ -1862,7 +1867,6 @@ class TextEditorComponent {
|
||||
handleMouseDragUntilMouseUp ({didDrag, didStopDragging}) {
|
||||
let dragging = false
|
||||
let lastMousemoveEvent
|
||||
let bufferWillChangeDisposable
|
||||
|
||||
const animationFrameLoop = () => {
|
||||
window.requestAnimationFrame(() => {
|
||||
@@ -1882,9 +1886,9 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
function didMouseUp () {
|
||||
this.stopDragging = null
|
||||
window.removeEventListener('mousemove', didMouseMove)
|
||||
window.removeEventListener('mouseup', didMouseUp, {capture: true})
|
||||
bufferWillChangeDisposable.dispose()
|
||||
if (dragging) {
|
||||
dragging = false
|
||||
didStopDragging()
|
||||
@@ -1893,10 +1897,7 @@ class TextEditorComponent {
|
||||
|
||||
window.addEventListener('mousemove', didMouseMove)
|
||||
window.addEventListener('mouseup', didMouseUp, {capture: true})
|
||||
// Simulate a mouse-up event if the buffer is about to change. This prevents
|
||||
// unwanted selections when users perform edits while holding the left mouse
|
||||
// button at the same time.
|
||||
bufferWillChangeDisposable = this.props.model.getBuffer().onWillChange(didMouseUp)
|
||||
this.stopDragging = didMouseUp
|
||||
}
|
||||
|
||||
autoscrollOnMouseDrag ({clientX, clientY}, verticalOnly = false) {
|
||||
|
||||
Reference in New Issue
Block a user