diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index c13c525cb..4b518837c 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -926,6 +926,13 @@ describe "Editor", -> editor.lines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 2 }) expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 27]] + describe "when it is a triple-click", -> + it "expands the selection to include the triple-clicked line", -> + editor.lines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 1 }) + editor.lines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 2 }) + editor.lines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 3 }) + expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 30]] + describe "select-to-top", -> it "selects text from cusor position to the top of the buffer", -> editor.setCursorScreenPosition [11,2] diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 2a0c231c1..01fedf2d0 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -126,6 +126,9 @@ class Cursor extends View getCurrentWordBufferRange: -> new Range(@getBeginningOfCurrentWordBufferPosition(allowPrevious: false), @getEndOfCurrentWordBufferPosition(allowNext: false)) + getCurrentLineBufferRange: -> + @editor.rangeForBufferRow(@getBufferPosition().row) + moveToEndOfLine: -> { row } = @getBufferPosition() @setBufferPosition({ row, column: @editor.buffer.lineForRow(row).length }) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index bc442be04..1e93c1186 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -145,7 +145,10 @@ class Editor extends View else @compositeSelection.getLastSelection().selectWord() else if clickCount >= 3 - @compositeSelection.getLastSelection().selectLine() + if e.shiftKey + @compositeSelection.getLastSelection().expandOverLine() + else + @compositeSelection.getLastSelection().selectLine() @selectOnMousemoveUntilMouseup() diff --git a/src/app/selection.coffee b/src/app/selection.coffee index 6404eed40..cbdddf7ba 100644 --- a/src/app/selection.coffee +++ b/src/app/selection.coffee @@ -166,8 +166,10 @@ class Selection extends View @setBufferRange(@getBufferRange().union(@cursor.getCurrentWordBufferRange())) selectLine: (row=@cursor.getBufferPosition().row) -> - rowLength = @editor.buffer.lineForRow(row).length - @setBufferRange new Range([row, 0], [row, rowLength]) + @setBufferRange(@editor.rangeForBufferRow(row)) + + expandOverLine: -> + @setBufferRange(@getBufferRange().union(@cursor.getCurrentLineBufferRange())) selectToScreenPosition: (position) -> @modifySelection => @cursor.setScreenPosition(position)