diff --git a/spec/atom/selection-spec.coffee b/spec/atom/selection-spec.coffee index 71621479b..2aee7bbcb 100644 --- a/spec/atom/selection-spec.coffee +++ b/spec/atom/selection-spec.coffee @@ -184,8 +184,8 @@ describe "Selection", -> selection.selectWord() expect(selection.getText()).toBe '' - describe ".selectLine()", -> - it "selects the entire line the cursor is on", -> - editor.setCursorPosition [1,2] - selection.selectLine() + describe ".selectLine(row)", -> + it "selects the entire line at given row", -> + editor.setCursorPosition [0,2] + selection.selectLine(1) expect(selection.getText()).toBe " var sort = function(items) {" diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index 2d9d97dde..65cff93bb 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -86,7 +86,7 @@ class Editor extends Template else if clickCount == 2 @selection.selectWord() else if clickCount >= 3 - @selection.selectLine() + @selection.selectLine(@getCursorRow()) @selectTextOnMouseMovement() diff --git a/src/atom/selection.coffee b/src/atom/selection.coffee index 3a5598b2f..598ecef10 100644 --- a/src/atom/selection.coffee +++ b/src/atom/selection.coffee @@ -114,9 +114,9 @@ class Selection extends Template range = new Range([row, column + startOffset], [row, column + endOffset]) @setRange range - selectLine: -> - row = @cursor.getRow() - @setRange new Range([row, 0], [row, @editor.getCurrentLine().length]) + selectLine: (row) -> + rowLength = @editor.buffer.getLine(row).length + @setRange new Range([row, 0], [row, rowLength]) selectRight: -> @modifySelection =>