From bc391094df0026c41bc2a4ae31bcb70198c5a0b1 Mon Sep 17 00:00:00 2001 From: Ben Ogle & Nathan Sobo Date: Wed, 18 Jun 2014 16:52:31 -0700 Subject: [PATCH 1/8] :lipstick: Move helper --- spec/editor-component-spec.coffee | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index fd068f656..b11d523d1 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -916,7 +916,7 @@ describe "EditorComponent", -> expect(inputNode.offsetTop).toBe 0 expect(inputNode.offsetLeft).toBe 0 - describe "mouse interactions", -> + describe "mouse interactions on the scrollView", -> linesNode = null beforeEach -> @@ -1017,12 +1017,6 @@ describe "EditorComponent", -> linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([4, 8]), {target})) expect(editor.isFoldedAtBufferRow 4).toBe false - clientCoordinatesForScreenPosition = (screenPosition) -> - positionOffset = editor.pixelPositionForScreenPosition(screenPosition) - scrollViewClientRect = node.querySelector('.scroll-view').getBoundingClientRect() - clientX = scrollViewClientRect.left + positionOffset.left - editor.getScrollLeft() - clientY = scrollViewClientRect.top + positionOffset.top - editor.getScrollTop() - {clientX, clientY} describe "focus handling", -> inputNode = null @@ -1443,3 +1437,11 @@ describe "EditorComponent", -> Object.defineProperty(event, 'target', get: -> properties.target) Object.defineProperty(event, 'srcObject', get: -> properties.target) event + + clientCoordinatesForScreenPosition = (screenPosition) -> + positionOffset = editor.pixelPositionForScreenPosition(screenPosition) + scrollViewClientRect = node.querySelector('.scroll-view').getBoundingClientRect() + clientX = scrollViewClientRect.left + positionOffset.left - editor.getScrollLeft() + clientY = scrollViewClientRect.top + positionOffset.top - editor.getScrollTop() + {clientX, clientY} + From 9083103bb383a1f95f365d2acad35712f02aac64 Mon Sep 17 00:00:00 2001 From: Ben Ogle & Nathan Sobo Date: Wed, 18 Jun 2014 16:54:08 -0700 Subject: [PATCH 2/8] Add click and shift-click in gutter --- spec/editor-component-spec.coffee | 30 ++++++++++++++++++++++++++++++ src/editor-component.coffee | 19 +++++++++++++++++-- src/gutter-component.coffee | 4 ++-- src/selection.coffee | 12 ++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index b11d523d1..d7409fc64 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -1017,6 +1017,30 @@ describe "EditorComponent", -> linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([4, 8]), {target})) expect(editor.isFoldedAtBufferRow 4).toBe false + describe "mouse interactions on the gutter", -> + gutterNode = null + + beforeEach -> + gutterNode = node.querySelector('.gutter') + + describe "when the gutter is clicked", -> + it "moves the cursor to the beginning of the clicked row", -> + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(4))) + expect(editor.getCursorScreenPosition()).toEqual [4, 0] + + describe "when the gutter is shift-clicked", -> + beforeEach -> + editor.setSelectedScreenRange([[3, 4], [4, 5]]) + + describe "when the clicked row is before the current selection's tail", -> + it "selects to the beginning of the clicked row", -> + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(1), shiftKey: true)) + expect(editor.getSelectedScreenRange()).toEqual [[1, 0], [3, 4]] + + describe "when the clicked row is after the current selection's tail", -> + it "selects to the beginning of the row following the clicked row", -> + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(6), shiftKey: true)) + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [7, 0]] describe "focus handling", -> inputNode = null @@ -1445,3 +1469,9 @@ describe "EditorComponent", -> clientY = scrollViewClientRect.top + positionOffset.top - editor.getScrollTop() {clientX, clientY} + clientCoordinatesForScreenRowInGutter = (screenRow) -> + positionOffset = editor.pixelPositionForScreenPosition([screenRow, 1]) + gutterClientRect = node.querySelector('.gutter').getBoundingClientRect() + clientX = gutterClientRect.left + positionOffset.left - editor.getScrollLeft() + clientY = gutterClientRect.top + positionOffset.top - editor.getScrollTop() + {clientX, clientY} diff --git a/src/editor-component.coffee b/src/editor-component.coffee index d520ad1dc..1be090377 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -79,8 +79,8 @@ EditorComponent = React.createClass div className: className, style: {fontSize, lineHeight, fontFamily}, tabIndex: -1, GutterComponent { - ref: 'gutter', onWidthChanged: @onGutterWidthChanged, lineDecorations, defaultCharWidth, - editor, renderedRowRange, maxLineNumberDigits, scrollViewHeight, + ref: 'gutter', onMouseDown: @onGutterMouseDown, onWidthChanged: @onGutterWidthChanged, + lineDecorations, defaultCharWidth, editor, renderedRowRange, maxLineNumberDigits, scrollViewHeight, scrollTop, scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow } @@ -505,6 +505,21 @@ EditorComponent = React.createClass when 3 then editor.selectLine() @selectToMousePositionUntilMouseUp(event) + onGutterMouseDown: (event) -> + return unless event.button is 0 # only handle the left mouse button + + {editor} = @props + {shiftKey, metaKey} = event + clickedRow = @screenPositionForMouseEvent(event).row + + if shiftKey + tailRow = editor.getSelection().getTailScreenPosition().row + if clickedRow < tailRow + editor.selectToScreenPosition([clickedRow, 0]) + else + editor.selectToScreenPosition([clickedRow + 1, 0]) + else + editor.setCursorScreenPosition([clickedRow, 0]) onStylesheetsChanged: (stylesheet) -> @refreshScrollbars() if @containsScrollbarSelector(stylesheet) diff --git a/src/gutter-component.coffee b/src/gutter-component.coffee index 0f9a55c75..5fc1a1730 100644 --- a/src/gutter-component.coffee +++ b/src/gutter-component.coffee @@ -15,9 +15,9 @@ GutterComponent = React.createClass measuredWidth: null render: -> - {scrollHeight, scrollViewHeight, scrollTop} = @props + {scrollHeight, scrollViewHeight, scrollTop, onMouseDown} = @props - div className: 'gutter', onClick: @onClick, + div className: 'gutter', onClick: @onClick, onMouseDown: onMouseDown, # The line-numbers div must have the 'editor-colors' class so it has an # opaque background to avoid sub-pixel anti-aliasing problems on the GPU div className: 'gutter line-numbers editor-colors', ref: 'lineNumbers', style: diff --git a/src/selection.coffee b/src/selection.coffee index c09ed1f53..438a60348 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -91,6 +91,18 @@ class Selection extends Model end = Math.max(start, end - 1) if range.end.column == 0 [start, end] + getTailScreenPosition: -> + @marker.getTailScreenPosition() + + getTailBufferPosition: -> + @marker.getTailBufferPosition() + + getHeadScreenPosition: -> + @marker.getHeadScreenPosition() + + getHeadBufferPosition: -> + @marker.getHeadBufferPosition() + autoscroll: -> @editor.scrollToScreenRange(@getScreenRange()) From 2edcc517b1600d9582c71ac4202490681993bbf9 Mon Sep 17 00:00:00 2001 From: Ben Ogle & Nathan Sobo Date: Wed, 18 Jun 2014 17:48:28 -0700 Subject: [PATCH 3/8] Handle dragging in the gutter Including shift-click dragging better than the old editor!!!!!! --- spec/editor-component-spec.coffee | 70 +++++++++++++++++++++++++++++++ src/editor-component.coffee | 31 ++++++++++---- 2 files changed, 92 insertions(+), 9 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index d7409fc64..6b988f818 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -1042,6 +1042,76 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(6), shiftKey: true)) expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [7, 0]] + describe "when the gutter is clicked and dragged", -> + beforeEach -> + delayAnimationFrames = true + + describe "when dragging downward", -> + it "selects the rows between the start and end of the drag", -> + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(2))) + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(6))) + nextAnimationFrame() + gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(6))) + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] + + describe "when dragging upward", -> + it "selects the rows between the start and end of the drag", -> + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(6))) + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(2))) + nextAnimationFrame() + gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(2))) + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] + + describe "when the gutter is shift-clicked and dragged", -> + beforeEach -> + delayAnimationFrames = true + + describe "when the shift-click is below the existing selection's tail", -> + describe "when dragging downward", -> + it "selects the rows between the existing selection's tail and the end of the drag", -> + editor.setSelectedScreenRange([[3, 4], [4, 5]]) + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(7), shiftKey: true)) + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] + + describe "when dragging upward", -> + it "selects the rows between the end of the drag and the tail of the existing selection", -> + editor.setSelectedScreenRange([[4, 4], [5, 5]]) + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(7), shiftKey: true)) + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(5))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[4, 4], [6, 0]] + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(1))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[1, 0], [4, 4]] + + describe "when the shift-click is above the existing selection's tail", -> + describe "when dragging upward", -> + it "selects the rows between the end of the drag and the tail of the existing selection", -> + editor.setSelectedScreenRange([[4, 4], [5, 5]]) + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(2), shiftKey: true)) + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(1))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[1, 0], [4, 4]] + + describe "when dragging downward", -> + it "selects the rows between the existing selection's tail and the end of the drag", -> + editor.setSelectedScreenRange([[3, 4], [4, 5]]) + gutterNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenRowInGutter(1), shiftKey: true)) + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(2))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [3, 4]] + + gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) + nextAnimationFrame() + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] + describe "focus handling", -> inputNode = null diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 1be090377..ea9d6aea3 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -504,23 +504,39 @@ EditorComponent = React.createClass when 2 then editor.selectWord() when 3 then editor.selectLine() - @selectToMousePositionUntilMouseUp(event) + @handleDragUntilMouseUp event, (screenPosition) -> + editor.selectToScreenPosition(screenPosition) + onGutterMouseDown: (event) -> return unless event.button is 0 # only handle the left mouse button {editor} = @props {shiftKey, metaKey} = event clickedRow = @screenPositionForMouseEvent(event).row + tailPosition = editor.getSelection().getTailScreenPosition() if shiftKey - tailRow = editor.getSelection().getTailScreenPosition().row - if clickedRow < tailRow + if clickedRow < tailPosition.row editor.selectToScreenPosition([clickedRow, 0]) else editor.selectToScreenPosition([clickedRow + 1, 0]) else + tailRow = clickedRow editor.setCursorScreenPosition([clickedRow, 0]) + @handleDragUntilMouseUp event, (screenPosition) -> + dragRow = screenPosition.row + if shiftKey + if dragRow < tailPosition.row # up + editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) + else + editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) + else + if dragRow < tailRow # up + editor.setSelectedScreenRange([[dragRow, 0], [tailRow + 1, 0]]) + else + editor.setSelectedScreenRange([[tailRow, 0], [dragRow + 1, 0]]) + onStylesheetsChanged: (stylesheet) -> @refreshScrollbars() if @containsScrollbarSelector(stylesheet) @@ -579,15 +595,15 @@ EditorComponent = React.createClass onCharacterWidthsChanged: (@scopedCharacterWidthsChangeCount) -> @requestUpdate() - selectToMousePositionUntilMouseUp: (event) -> + handleDragUntilMouseUp: (event, dragHandler) -> {editor} = @props dragging = false lastMousePosition = {} - animationLoop = => requestAnimationFrame => if dragging - @selectToMousePosition(lastMousePosition) + screenPosition = @screenPositionForMouseEvent(lastMousePosition) + dragHandler(screenPosition) animationLoop() onMouseMove = (event) -> @@ -611,9 +627,6 @@ EditorComponent = React.createClass window.addEventListener('mousemove', onMouseMove) window.addEventListener('mouseup', onMouseUp) - selectToMousePosition: (event) -> - @props.editor.selectToScreenPosition(@screenPositionForMouseEvent(event)) - requestScrollViewMeasurement: -> return if @measurementPending From 8295019891c54314bcf451287864f9983efa9024 Mon Sep 17 00:00:00 2001 From: Ben Ogle & Nathan Sobo Date: Wed, 18 Jun 2014 17:48:42 -0700 Subject: [PATCH 4/8] Throw error when no animation frame was requested --- spec/editor-component-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 6b988f818..de7439917 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -19,7 +19,7 @@ describe "EditorComponent", -> spyOn(window, "clearInterval").andCallFake window.fakeClearInterval delayAnimationFrames = false - nextAnimationFrame = null + nextAnimationFrame = -> throw new Error('No animation frame requested') spyOn(window, 'requestAnimationFrame').andCallFake (fn) -> if delayAnimationFrames nextAnimationFrame = fn From d3e0005b330d2b5811ab3536bdf75e4d2138647c Mon Sep 17 00:00:00 2001 From: Ben Ogle & Nathan Sobo Date: Wed, 18 Jun 2014 17:55:38 -0700 Subject: [PATCH 5/8] :lipstick: Break out separate methods for gutter click and shift-click --- src/editor-component.coffee | 50 +++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/editor-component.coffee b/src/editor-component.coffee index ea9d6aea3..4eebad236 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -510,32 +510,40 @@ EditorComponent = React.createClass onGutterMouseDown: (event) -> return unless event.button is 0 # only handle the left mouse button - {editor} = @props - {shiftKey, metaKey} = event - clickedRow = @screenPositionForMouseEvent(event).row - tailPosition = editor.getSelection().getTailScreenPosition() - - if shiftKey - if clickedRow < tailPosition.row - editor.selectToScreenPosition([clickedRow, 0]) - else - editor.selectToScreenPosition([clickedRow + 1, 0]) + if event.shiftKey + @onGutterShiftClick(event) else - tailRow = clickedRow - editor.setCursorScreenPosition([clickedRow, 0]) + @onGutterClick(event) + + onGutterClick: (event) -> + {editor} = @props + clickedRow = @screenPositionForMouseEvent(event).row + + editor.setCursorScreenPosition([clickedRow, 0]) @handleDragUntilMouseUp event, (screenPosition) -> dragRow = screenPosition.row - if shiftKey - if dragRow < tailPosition.row # up - editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) - else - editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) + if dragRow < tailRow # up + editor.setSelectedScreenRange([[dragRow, 0], [clickedRow + 1, 0]]) else - if dragRow < tailRow # up - editor.setSelectedScreenRange([[dragRow, 0], [tailRow + 1, 0]]) - else - editor.setSelectedScreenRange([[tailRow, 0], [dragRow + 1, 0]]) + editor.setSelectedScreenRange([[clickedRow, 0], [dragRow + 1, 0]]) + + onGutterShiftClick: (event) -> + {editor} = @props + clickedRow = @screenPositionForMouseEvent(event).row + tailPosition = editor.getSelection().getTailScreenPosition() + + if clickedRow < tailPosition.row + editor.selectToScreenPosition([clickedRow, 0]) + else + editor.selectToScreenPosition([clickedRow + 1, 0]) + + @handleDragUntilMouseUp event, (screenPosition) -> + dragRow = screenPosition.row + if dragRow < tailPosition.row # up + editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) + else + editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) onStylesheetsChanged: (stylesheet) -> @refreshScrollbars() if @containsScrollbarSelector(stylesheet) From 77717d3eff9b0f334a18aa991383b33e981c6226 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 18 Jun 2014 18:08:47 -0700 Subject: [PATCH 6/8] Fix spec --- src/editor-component.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 4eebad236..7398f7632 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -523,7 +523,7 @@ EditorComponent = React.createClass @handleDragUntilMouseUp event, (screenPosition) -> dragRow = screenPosition.row - if dragRow < tailRow # up + if dragRow < clickedRow # dragging up editor.setSelectedScreenRange([[dragRow, 0], [clickedRow + 1, 0]]) else editor.setSelectedScreenRange([[clickedRow, 0], [dragRow + 1, 0]]) @@ -540,7 +540,7 @@ EditorComponent = React.createClass @handleDragUntilMouseUp event, (screenPosition) -> dragRow = screenPosition.row - if dragRow < tailPosition.row # up + if dragRow < tailPosition.row # dragging up editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) else editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) From c5815d2af9e712d6a574aecd1b5f121e8b8b3c42 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 18 Jun 2014 18:17:29 -0700 Subject: [PATCH 7/8] Select to the end of the last row rather than beginning of row + 1 --- spec/editor-component-spec.coffee | 10 +++++----- src/editor-component.coffee | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index de7439917..9d0c7a61e 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -1052,7 +1052,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(6))) nextAnimationFrame() gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(6))) - expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [6, 65]] describe "when dragging upward", -> it "selects the rows between the start and end of the drag", -> @@ -1060,7 +1060,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(2))) nextAnimationFrame() gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(2))) - expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [6, 65]] describe "when the gutter is shift-clicked and dragged", -> beforeEach -> @@ -1074,7 +1074,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [8, 56]] describe "when dragging upward", -> it "selects the rows between the end of the drag and the tail of the existing selection", -> @@ -1083,7 +1083,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(5))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[4, 4], [6, 0]] + expect(editor.getSelectedScreenRange()).toEqual [[4, 4], [5, 30]] gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(1))) nextAnimationFrame() @@ -1110,7 +1110,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [8, 56]] describe "focus handling", -> inputNode = null diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 7398f7632..7a2cd0d72 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -524,9 +524,9 @@ EditorComponent = React.createClass @handleDragUntilMouseUp event, (screenPosition) -> dragRow = screenPosition.row if dragRow < clickedRow # dragging up - editor.setSelectedScreenRange([[dragRow, 0], [clickedRow + 1, 0]]) + editor.setSelectedScreenRange([[dragRow, 0], [clickedRow, Infinity]]) else - editor.setSelectedScreenRange([[clickedRow, 0], [dragRow + 1, 0]]) + editor.setSelectedScreenRange([[clickedRow, 0], [dragRow, Infinity]]) onGutterShiftClick: (event) -> {editor} = @props @@ -543,7 +543,7 @@ EditorComponent = React.createClass if dragRow < tailPosition.row # dragging up editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) else - editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) + editor.setSelectedScreenRange([tailPosition, [dragRow, Infinity]]) onStylesheetsChanged: (stylesheet) -> @refreshScrollbars() if @containsScrollbarSelector(stylesheet) From bee4c9df8a96aa29d6a3b5bdafe9524ea213d5f2 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 19 Jun 2014 12:06:09 -0700 Subject: [PATCH 8/8] Revert "Select to the end of the last row rather than beginning of row + 1" This reverts commit c5815d2af9e712d6a574aecd1b5f121e8b8b3c42. --- spec/editor-component-spec.coffee | 10 +++++----- src/editor-component.coffee | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 9d0c7a61e..de7439917 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -1052,7 +1052,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(6))) nextAnimationFrame() gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(6))) - expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [6, 65]] + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] describe "when dragging upward", -> it "selects the rows between the start and end of the drag", -> @@ -1060,7 +1060,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(2))) nextAnimationFrame() gutterNode.dispatchEvent(buildMouseEvent('mouseup', clientCoordinatesForScreenRowInGutter(2))) - expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [6, 65]] + expect(editor.getSelectedScreenRange()).toEqual [[2, 0], [7, 0]] describe "when the gutter is shift-clicked and dragged", -> beforeEach -> @@ -1074,7 +1074,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [8, 56]] + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] describe "when dragging upward", -> it "selects the rows between the end of the drag and the tail of the existing selection", -> @@ -1083,7 +1083,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(5))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[4, 4], [5, 30]] + expect(editor.getSelectedScreenRange()).toEqual [[4, 4], [6, 0]] gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(1))) nextAnimationFrame() @@ -1110,7 +1110,7 @@ describe "EditorComponent", -> gutterNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenRowInGutter(8))) nextAnimationFrame() - expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [8, 56]] + expect(editor.getSelectedScreenRange()).toEqual [[3, 4], [9, 0]] describe "focus handling", -> inputNode = null diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 7a2cd0d72..7398f7632 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -524,9 +524,9 @@ EditorComponent = React.createClass @handleDragUntilMouseUp event, (screenPosition) -> dragRow = screenPosition.row if dragRow < clickedRow # dragging up - editor.setSelectedScreenRange([[dragRow, 0], [clickedRow, Infinity]]) + editor.setSelectedScreenRange([[dragRow, 0], [clickedRow + 1, 0]]) else - editor.setSelectedScreenRange([[clickedRow, 0], [dragRow, Infinity]]) + editor.setSelectedScreenRange([[clickedRow, 0], [dragRow + 1, 0]]) onGutterShiftClick: (event) -> {editor} = @props @@ -543,7 +543,7 @@ EditorComponent = React.createClass if dragRow < tailPosition.row # dragging up editor.setSelectedScreenRange([[dragRow, 0], tailPosition]) else - editor.setSelectedScreenRange([tailPosition, [dragRow, Infinity]]) + editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]]) onStylesheetsChanged: (stylesheet) -> @refreshScrollbars() if @containsScrollbarSelector(stylesheet)