This commit is contained in:
Kevin Sawicki
2012-10-01 12:11:30 -07:00
parent 887720e4de
commit f2306f444a
4 changed files with 7 additions and 8 deletions

View File

@@ -1635,7 +1635,7 @@ describe "Editor", ->
it "doesn't highlight the backround", ->
editor.getSelection().setBufferRange(new Range([0,0],[2,0]))
expect(editor.getSelection().isMultiLine()).toBe true
expect(editor.getSelection().isSingleScreenLine()).toBe false
expect(editor.find('.line-number.cursor-line-number').length).toBe 1
expect(editor.find('.line-number.cursor-line-number.cursor-line-number-background').length).toBe 0
expect(editor.find('.line-number.cursor-line-number').text()).toBe "3"
@@ -1683,13 +1683,13 @@ describe "Editor", ->
describe "when there is a selection", ->
it "highlights if the selection is contained to one line", ->
editor.getSelection().setBufferRange(new Range([0,0],[0,1]))
expect(editor.getSelection().isMultiLine()).toBe false
expect(editor.getSelection().isSingleScreenLine()).toBe true
expect(editor.find('.line.cursor-line').length).toBe 1
expect(editor.find('.line.cursor-line').text()).toBe buffer.lineForRow(0)
it "doesn't highlight if the selection spans multiple lines", ->
editor.getSelection().setBufferRange(new Range([0,0],[2,0]))
expect(editor.getSelection().isMultiLine()).toBe true
expect(editor.getSelection().isSingleScreenLine()).toBe false
expect(editor.find('.line.cursor-line').length).toBe 0
describe "folding", ->

View File

@@ -954,5 +954,5 @@ class Editor extends View
@cursorScreenRow = @getCursorScreenPosition().row
screenRow = @cursorScreenRow - @firstRenderedScreenRow
@find('pre.line.cursor-line').removeClass('cursor-line')
if !@getSelection().isMultiLine()
if @getSelection().isSingleScreenLine()
@find("pre.line:eq(#{screenRow})").addClass('cursor-line')

View File

@@ -69,5 +69,5 @@ class Gutter extends View
newLineNumberRow = @find(".line-number:eq(#{screenRowIndex})")
newLineNumberRow.addClass('cursor-line-number')
if !@editor().getSelection().isMultiLine()
if @editor().getSelection().isSingleScreenLine()
newLineNumberRow.addClass('cursor-line-number-background')

View File

@@ -31,9 +31,8 @@ class Selection
isReversed: ->
not @isEmpty() and @cursor.getBufferPosition().isLessThan(@anchor.getBufferPosition())
isMultiLine: ->
range = @getScreenRange()
range.start.row != range.end.row
isSingleScreenLine: ->
@getScreenRange().isSingleLine()
getScreenRange: ->
if @anchor