mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Selections render correctly with wrapped lines.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user