mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Don't highlight line if selection is multiline
This commit is contained in:
@@ -1619,10 +1619,10 @@ describe "Editor", ->
|
||||
expect(editor.find('.line-number.cursor-line-number').text()).toBe "2"
|
||||
|
||||
describe "line highlighting", ->
|
||||
describe "when there is no wrapping", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(30)
|
||||
beforeEach ->
|
||||
editor.attachToDom(30)
|
||||
|
||||
describe "when there is no wrapping", ->
|
||||
it "highlights the line where the initial cursor position is", ->
|
||||
expect(editor.getCursorBufferPosition().row).toBe 0
|
||||
expect(editor.find('.line.cursor-line').length).toBe 1
|
||||
@@ -1636,7 +1636,6 @@ describe "Editor", ->
|
||||
|
||||
describe "when there is wrapping", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(30)
|
||||
editor.setSoftWrap(true)
|
||||
setEditorWidthInChars(editor, 20)
|
||||
|
||||
@@ -1651,6 +1650,18 @@ describe "Editor", ->
|
||||
expect(editor.find('.line.cursor-line').length).toBe 1
|
||||
expect(editor.find('.line.cursor-line').text()).toBe ' var sort = '
|
||||
|
||||
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.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.find('.line.cursor-line').length).toBe 0
|
||||
|
||||
describe "folding", ->
|
||||
beforeEach ->
|
||||
editSession = rootView.project.buildEditSessionForPath('two-hundred.txt')
|
||||
|
||||
@@ -943,4 +943,5 @@ class Editor extends View
|
||||
@cursorScreenRow = @getCursorScreenPosition().row
|
||||
screenRow = @cursorScreenRow - @firstRenderedScreenRow
|
||||
@find('.line.cursor-line').removeClass('cursor-line')
|
||||
@find(".line:eq(#{screenRow})").addClass('cursor-line')
|
||||
if !@getSelection().isMultiLine()
|
||||
@find(".line:eq(#{screenRow})").addClass('cursor-line')
|
||||
|
||||
@@ -31,6 +31,10 @@ class Selection
|
||||
isReversed: ->
|
||||
not @isEmpty() and @cursor.getBufferPosition().isLessThan(@anchor.getBufferPosition())
|
||||
|
||||
isMultiLine: ->
|
||||
range = @getScreenRange()
|
||||
range.start.row != range.end.row
|
||||
|
||||
getScreenRange: ->
|
||||
if @anchor
|
||||
new Range(@anchor.getScreenPosition(), @cursor.getScreenPosition())
|
||||
|
||||
Reference in New Issue
Block a user