diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index 004f8166a..35cf9847f 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -56,7 +56,7 @@ describe "Editor", -> editor.width(editor.charWidth * 50) editor.setSoftWrap(true) - it "wraps lines that are too long to fit within the editor's width, adjusting cursor positioning accordingly", -> + fit "wraps lines that are too long to fit within the editor's width, adjusting cursor positioning accordingly", -> expect(editor.lines.find('.line').length).toBe 16 expect(editor.lines.find('pre:eq(3)').text()).toBe " var pivot = items.shift(), current, left = [], " expect(editor.lines.find('pre:eq(4)').text()).toBe "right = [];" @@ -67,6 +67,11 @@ describe "Editor", -> editor.cursor.setPosition([4, 0]) expect(editor.cursor.position()).toEqual(editor.lines.find('pre:eq(5)').position()) + editor.selection.setRange(new Range([6, 30], [6, 55])) + [region1, region2] = editor.selection.regions + expect(region1.position().top).toBe(editor.lines.find('.line:eq(7)').position().top) + expect(region2.position().top).toBe(editor.lines.find('.line:eq(8)').position().top) + # Many more tests for change events in the LineWrapper spec it "handles changes to wrapped lines correctly", -> buffer.insert([6, 28], '1234567') diff --git a/src/atom/selection.coffee b/src/atom/selection.coffee index 18949df61..b4eaa02be 100644 --- a/src/atom/selection.coffee +++ b/src/atom/selection.coffee @@ -27,7 +27,7 @@ class Selection extends View updateAppearance: -> @clearRegions() - range = @getRange() + range = @getScreenRange() return if range.isEmpty() rowSpan = range.end.row - range.start.row @@ -70,6 +70,9 @@ class Selection extends View @modifySelection => @cursor.setPosition(range.end) + getScreenRange: -> + @editor.lineWrapper.screenRangeFromBufferRange(@getRange()) + getText: -> @editor.buffer.getTextInRange @getRange()