mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Support clicking line numbers in gutter
Clicking moves the cursor to the start of the row and shift-clicking selects to the start of the row
This commit is contained in:
@@ -1990,3 +1990,15 @@ describe "Editor", ->
|
||||
|
||||
runs ->
|
||||
expect(editor.getText()).toBe(originalPathText)
|
||||
|
||||
describe "when clicking a gutter line", ->
|
||||
it "moves the cursor to the start of the selected line", ->
|
||||
rootView.attachToDom()
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0,0]
|
||||
editor.gutter.find(".line-number:eq(1)").trigger 'click'
|
||||
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]
|
||||
editor.gutter.find(".line-number:eq(1)").trigger 'click', {shiftKey: true}
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [0,0], [1,0]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
Range = require 'range'
|
||||
Point = require 'point'
|
||||
|
||||
module.exports =
|
||||
class Gutter extends View
|
||||
@@ -22,6 +23,14 @@ class Gutter extends View
|
||||
highlightLines = => @highlightLines()
|
||||
editor.on 'cursor-move', highlightLines
|
||||
editor.on 'selection-change', highlightLines
|
||||
@on 'click', '.line-number', (e) =>
|
||||
row = parseInt($(e.target).text()) - 1
|
||||
position = new Point(row, 0)
|
||||
if e.shiftKey
|
||||
@editor().selectToScreenPosition(position)
|
||||
else
|
||||
@editor().setCursorScreenPosition(position)
|
||||
|
||||
@calculateWidth()
|
||||
|
||||
editor: ->
|
||||
|
||||
Reference in New Issue
Block a user