mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
Select words on double-click
This commit is contained in:
parent
cbad8a56ec
commit
2204571ef5
@ -198,6 +198,14 @@ describe "EditorComponent", ->
|
|||||||
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([5, 6]), metaKey: true))
|
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([5, 6]), metaKey: true))
|
||||||
expect(editor.getSelectedScreenRanges()).toEqual [[[3, 4], [3, 4]], [[5, 6], [5, 6]]]
|
expect(editor.getSelectedScreenRanges()).toEqual [[[3, 4], [3, 4]], [[5, 6], [5, 6]]]
|
||||||
|
|
||||||
|
describe "when a non-folded line is double-clicked", ->
|
||||||
|
it "selects the word containing the nearest screen position", ->
|
||||||
|
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([5, 10]), detail: 2))
|
||||||
|
expect(editor.getSelectedScreenRange()).toEqual [[5, 6], [5, 13]]
|
||||||
|
|
||||||
|
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([6, 6]), detail: 1))
|
||||||
|
expect(editor.getSelectedScreenRange()).toEqual [[6, 6], [6, 6]]
|
||||||
|
|
||||||
describe "when the mouse is clicked and dragged", ->
|
describe "when the mouse is clicked and dragged", ->
|
||||||
it "selects to the nearest screen position until the mouse button is released", ->
|
it "selects to the nearest screen position until the mouse button is released", ->
|
||||||
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([2, 4]), which: 1))
|
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([2, 4]), which: 1))
|
||||||
|
@ -271,7 +271,7 @@ EditorCompont = React.createClass
|
|||||||
|
|
||||||
onMouseDown: (event) ->
|
onMouseDown: (event) ->
|
||||||
{editor} = @props
|
{editor} = @props
|
||||||
{shiftKey, metaKey} = event
|
{detail, shiftKey, metaKey} = event
|
||||||
screenPosition = @screenPositionForMouseEvent(event)
|
screenPosition = @screenPositionForMouseEvent(event)
|
||||||
|
|
||||||
if shiftKey
|
if shiftKey
|
||||||
@ -280,6 +280,8 @@ EditorCompont = React.createClass
|
|||||||
editor.addCursorAtScreenPosition(screenPosition)
|
editor.addCursorAtScreenPosition(screenPosition)
|
||||||
else
|
else
|
||||||
editor.setCursorScreenPosition(screenPosition)
|
editor.setCursorScreenPosition(screenPosition)
|
||||||
|
if detail is 2
|
||||||
|
editor.selectWord()
|
||||||
|
|
||||||
@selectToMousePositionUntilMouseUp(event)
|
@selectToMousePositionUntilMouseUp(event)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user