Shift-click creates a selection

It would be nice to handle shift-double-click and shift-triple-click as well.
This commit is contained in:
Nathan Sobo
2012-04-05 18:12:48 -06:00
parent fd3e98cd28
commit 2fc3f78e26
2 changed files with 12 additions and 0 deletions

View File

@@ -910,6 +910,16 @@ describe "Editor", ->
expect(range.end).toEqual({row: 5, column: 27})
expect(editor.getCursorScreenPosition()).toEqual(row: 5, column: 27)
describe "shift-click", ->
it "selects from the cursor's current location to the clicked location", ->
editor.attachToDom()
editor.css(position: 'absolute', top: 10, left: 10)
editor.setCursorScreenPosition([4, 7])
editor.lines.trigger mousedownEvent(editor: editor, point: [5, 27], shiftKey: true)
expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 27]]
describe "select-to-top", ->
it "selects text from cusor position to the top of the buffer", ->
editor.setCursorScreenPosition [11,2]

View File

@@ -135,6 +135,8 @@ class Editor extends View
screenPosition = @screenPositionFromMouseEvent(e)
if e.metaKey
@addCursorAtScreenPosition(screenPosition)
else if e.shiftKey
@selectToScreenPosition(@screenPositionFromMouseEvent(e))
else
@setCursorScreenPosition(screenPosition)
else if clickCount == 2