mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Support selecting editor lines from the gutter
Mouse events that occur in the gutter are forwarded to the rendered lines with the y-coordinate translated to be the leftmost pixel of the editor to simulate the event originating from column 0 of the current line row. Closes #287
This commit is contained in:
@@ -2225,21 +2225,44 @@ describe "Editor", ->
|
||||
runs ->
|
||||
expect(editor.getText()).toBe(originalPathText)
|
||||
|
||||
describe "when clicking a gutter line", ->
|
||||
describe "when clicking in the gutter", ->
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
editor.attachToDom()
|
||||
|
||||
it "moves the cursor to the start of the selected line", ->
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0,0]
|
||||
editor.gutter.find(".line-number:eq(1)").trigger 'click'
|
||||
expect(editor.getCursorScreenPosition()).toEqual [1,0]
|
||||
describe "when single clicking", ->
|
||||
it "moves the cursor to the start of the selected line", ->
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0,0]
|
||||
event = $.Event("mousedown")
|
||||
event.pageY = editor.gutter.find(".line-number:eq(1)").offset().top
|
||||
event.originalEvent = {detail: 1}
|
||||
editor.gutter.find(".line-number:eq(1)").trigger event
|
||||
expect(editor.getCursorScreenPosition()).toEqual [1,0]
|
||||
|
||||
it "selects to the start of the selected line when shift is pressed", ->
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [0,0]]
|
||||
event = $.Event("click")
|
||||
event.shiftKey = true
|
||||
editor.gutter.find(".line-number:eq(1)").trigger event
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [1,0]]
|
||||
describe "when shift-clicking", ->
|
||||
it "selects to the start of the selected line", ->
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [0,0]]
|
||||
event = $.Event("mousedown")
|
||||
event.pageY = editor.gutter.find(".line-number:eq(1)").offset().top
|
||||
event.originalEvent = {detail: 1}
|
||||
event.shiftKey = true
|
||||
editor.gutter.find(".line-number:eq(1)").trigger event
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [1,0]]
|
||||
|
||||
describe "when mousing down and then moving across multiple lines before mousing up", ->
|
||||
it "selects the lines", ->
|
||||
mousedownEvent = $.Event("mousedown")
|
||||
mousedownEvent.pageY = editor.gutter.find(".line-number:eq(1)").offset().top
|
||||
mousedownEvent.originalEvent = {detail: 1}
|
||||
editor.gutter.find(".line-number:eq(1)").trigger mousedownEvent
|
||||
|
||||
mousemoveEvent = $.Event("mousemove")
|
||||
mousemoveEvent.pageY = editor.gutter.find(".line-number:eq(5)").offset().top
|
||||
mousemoveEvent.originalEvent = {detail: 1}
|
||||
editor.gutter.find(".line-number:eq(5)").trigger mousemoveEvent
|
||||
|
||||
$(document).trigger 'mouseup'
|
||||
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[1,0], [5,30]]
|
||||
|
||||
describe "when clicking below the last line", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user