mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Selection merging with mouse maintains directionality of last selection
This commit is contained in:
@@ -1030,7 +1030,7 @@ describe "Editor", ->
|
||||
expect(selection1.getScreenRange()).toEqual [[4, 10], [5, 27]]
|
||||
expect(selection2.getScreenRange()).toEqual [[6, 10], [8, 27]]
|
||||
|
||||
it "merges selections when they intersect", ->
|
||||
it "merges selections when they intersect, maintaining the directionality of the newest selection", ->
|
||||
editor.attachToDom()
|
||||
editor.lines.trigger mousedownEvent(editor: editor, point: [4, 10])
|
||||
editor.lines.trigger mousemoveEvent(editor: editor, point: [5, 27])
|
||||
@@ -1044,6 +1044,17 @@ describe "Editor", ->
|
||||
expect(selections.length).toBe 1
|
||||
[selection1] = selections
|
||||
expect(selection1.getScreenRange()).toEqual [[3, 10], [6, 27]]
|
||||
expect(selection1.isReversed()).toBeFalsy()
|
||||
|
||||
editor.lines.trigger mousedownEvent(editor: editor, point: [7, 4], metaKey: true)
|
||||
editor.lines.trigger mousemoveEvent(editor: editor, point: [4, 11], metaKey: true)
|
||||
editor.lines.trigger 'mouseup'
|
||||
|
||||
selections = editor.compositeSelection.getSelections()
|
||||
expect(selections.length).toBe 1
|
||||
[selection1] = selections
|
||||
expect(selection1.getScreenRange()).toEqual [[3, 10], [7, 4]]
|
||||
expect(selection1.isReversed()).toBeTruthy()
|
||||
|
||||
describe "upon moving the cursor with the arrow keys with the shift key held down", ->
|
||||
it "resizes all selections", ->
|
||||
|
||||
@@ -41,7 +41,7 @@ class CompositeSeleciton
|
||||
@modifySelectedText (selection) -> selection.delete()
|
||||
|
||||
selectToScreenPosition: (position) ->
|
||||
@lastSelection().selectToScreenPosition(position)
|
||||
@getLastSelection().selectToScreenPosition(position)
|
||||
|
||||
selectRight: ->
|
||||
selection.selectRight() for selection in @getSelections()
|
||||
@@ -60,15 +60,15 @@ class CompositeSeleciton
|
||||
@mergeIntersectingSelections()
|
||||
|
||||
setBufferRange: (bufferRange, options) ->
|
||||
@lastSelection().setBufferRange(bufferRange, options)
|
||||
@getLastSelection().setBufferRange(bufferRange, options)
|
||||
|
||||
getBufferRange: (bufferRange) ->
|
||||
@lastSelection().getBufferRange()
|
||||
@getLastSelection().getBufferRange()
|
||||
|
||||
getText: ->
|
||||
@lastSelection().getText()
|
||||
@getLastSelection().getText()
|
||||
|
||||
lastSelection: ->
|
||||
getLastSelection: ->
|
||||
_.last(@selections)
|
||||
|
||||
mergeIntersectingSelections: (options) ->
|
||||
|
||||
@@ -138,9 +138,9 @@ class Editor extends View
|
||||
else
|
||||
@setCursorScreenPosition(screenPosition)
|
||||
else if clickCount == 2
|
||||
@compositeSelection.lastSelection().selectWord()
|
||||
@compositeSelection.getLastSelection().selectWord()
|
||||
else if clickCount >= 3
|
||||
@compositeSelection.lastSelection().selectLine()
|
||||
@compositeSelection.getLastSelection().selectLine()
|
||||
|
||||
@selectOnMousemoveUntilMouseup()
|
||||
|
||||
@@ -167,7 +167,8 @@ class Editor extends View
|
||||
@on 'mousemove', moveHandler
|
||||
$(document).one 'mouseup', =>
|
||||
@off 'mousemove', moveHandler
|
||||
@compositeSelection.mergeIntersectingSelections()
|
||||
reverse = @compositeSelection.getLastSelection().isReversed()
|
||||
@compositeSelection.mergeIntersectingSelections({reverse})
|
||||
|
||||
renderLines: ->
|
||||
@lineCache = []
|
||||
|
||||
@@ -140,7 +140,7 @@ class Selection extends View
|
||||
@getBufferRange().isEmpty()
|
||||
|
||||
isReversed: ->
|
||||
@cursor.getBufferPosition().isLessThan(@anchorBufferPosition)
|
||||
not @isEmpty() and @cursor.getBufferPosition().isLessThan(@anchorBufferPosition)
|
||||
|
||||
intersectsWith: (otherSelection) ->
|
||||
@getScreenRange().intersectsWith(otherSelection.getScreenRange())
|
||||
|
||||
2
vendor/jasmine-helper.coffee
vendored
2
vendor/jasmine-helper.coffee
vendored
@@ -22,4 +22,4 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
jasmineEnv = jasmine.getEnv()
|
||||
jasmineEnv.addReporter(reporter)
|
||||
jasmineEnv.specFilter = (spec) -> reporter.specFilter(spec)
|
||||
jasmineEnv.execute()
|
||||
jasmineEnv.execute()
|
||||
|
||||
Reference in New Issue
Block a user