Merge branch 'hide-selection-cursor'

This commit is contained in:
Nathan Sobo
2012-10-29 16:54:34 -06:00
9 changed files with 96 additions and 35 deletions

View File

@@ -1413,6 +1413,15 @@ describe "EditSession", ->
expect(buffer.lineForRow(11)).toBe " return sort(Array.apply(this, arguments));"
expect(editSession.getSelectedBufferRange()).toEqual [[9, 1 + editSession.tabLength], [11, 15 + editSession.tabLength]]
it "does not indent the last row if the selection ends at column 0", ->
editSession.tabLength = 2
editSession.setSelectedBufferRange([[9,1], [11,0]])
editSession.indentSelectedRows()
expect(buffer.lineForRow(9)).toBe " };"
expect(buffer.lineForRow(10)).toBe ""
expect(buffer.lineForRow(11)).toBe " return sort(Array.apply(this, arguments));"
expect(editSession.getSelectedBufferRange()).toEqual [[9, 1 + editSession.tabLength], [11, 0]]
describe "when softTabs is disabled", ->
it "indents selected lines (that are not empty) and retains selection", ->
convertToHardTabs(buffer)
@@ -1470,8 +1479,19 @@ describe "EditSession", ->
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
expect(buffer.lineForRow(1)).toBe "var sort = function(items) {"
expect(buffer.lineForRow(2)).toBe " if (items.length <= 1) return items;"
expect(buffer.lineForRow(3)).toBe " var pivot = items.shift(), current, left = [], right = [];"
expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [3, 15 - editSession.tabLength]]
it "does not outdent the last line of the selection if it ends at column 0", ->
editSession.setSelectedBufferRange([[0,1], [3,0]])
editSession.outdentSelectedRows()
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
expect(buffer.lineForRow(1)).toBe "var sort = function(items) {"
expect(buffer.lineForRow(2)).toBe " if (items.length <= 1) return items;"
expect(buffer.lineForRow(3)).toBe " var pivot = items.shift(), current, left = [], right = [];"
expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [3, 0]]
describe ".toggleLineCommentsInSelection()", ->
it "toggles comments on the selected lines", ->
editSession.setSelectedBufferRange([[4, 5], [7, 5]])
@@ -1489,6 +1509,14 @@ describe "EditSession", ->
expect(buffer.lineForRow(6)).toBe " current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe " }"
it "does not comment the last line of a non-empty selection if it ends at column 0", ->
editSession.setSelectedBufferRange([[4, 5], [7, 0]])
editSession.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe "// while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe "// current = items.shift();"
expect(buffer.lineForRow(6)).toBe "// current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe " }"
it "uncomments lines if the first line matches the comment regex", ->
editSession.setSelectedBufferRange([[4, 5], [4, 5]])
editSession.toggleLineCommentsInSelection()

View File

@@ -864,6 +864,19 @@ describe "Editor", ->
advanceClock(100)
expect(cursorView).toHaveClass 'idle'
it "hides the cursor when the selection is non-empty, and shows it otherwise", ->
cursorView = editor.getCursorView()
expect(editor.getSelection().isEmpty()).toBeTruthy()
expect(cursorView).toBeVisible()
editor.setSelectedBufferRange([[0, 0], [3, 0]])
expect(editor.getSelection().isEmpty()).toBeFalsy()
expect(cursorView).not.toBeVisible()
editor.setCursorBufferPosition([1, 3])
expect(editor.getSelection().isEmpty()).toBeTruthy()
expect(cursorView).toBeVisible()
describe "auto-scrolling", ->
it "only auto-scrolls when the last cursor is moved", ->
editor.setCursorBufferPosition([11,0])
@@ -1650,12 +1663,11 @@ describe "Editor", ->
beforeEach ->
editor.attachToDom(30)
it "doesn't highlight the backround", ->
it "doesn't highlight the background or the gutter", ->
editor.getSelection().setBufferRange(new Range([0,0],[2,0]))
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').length).toBe 0
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"
it "when a newline is deleted with backspace, the line number of the new cursor position is highlighted", ->
editor.setCursorScreenPosition([1,0])

View File

@@ -179,15 +179,15 @@ describe "LanguageMode", ->
editSession = fixturesProject.buildEditSessionForPath('sample.js', autoIndent: false)
{ buffer, languageMode } = editSession
describe ".toggleLineCommentsInRange(range)", ->
describe ".toggleLineCommentsForBufferRows(start, end)", ->
it "comments/uncomments lines in the given range", ->
languageMode.toggleLineCommentsInRange([[4, 5], [7, 8]])
languageMode.toggleLineCommentsForBufferRows(4, 7)
expect(buffer.lineForRow(4)).toBe "// while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe "// current = items.shift();"
expect(buffer.lineForRow(6)).toBe "// current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe "// }"
languageMode.toggleLineCommentsInRange([[4, 5], [5, 8]])
languageMode.toggleLineCommentsForBufferRows(4, 5)
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe " current = items.shift();"
expect(buffer.lineForRow(6)).toBe "// current < pivot ? left.push(current) : right.push(current);"
@@ -221,15 +221,15 @@ describe "LanguageMode", ->
editSession = fixturesProject.buildEditSessionForPath('coffee.coffee', autoIndent: false)
{ buffer, languageMode } = editSession
describe ".toggleLineCommentsInRange(range)", ->
describe ".toggleLineCommentsForBufferRows(start, end)", ->
it "comments/uncomments lines in the given range", ->
languageMode.toggleLineCommentsInRange([[4, 5], [7, 8]])
languageMode.toggleLineCommentsForBufferRows(4, 7)
expect(buffer.lineForRow(4)).toBe "# pivot = items.shift()"
expect(buffer.lineForRow(5)).toBe "# left = []"
expect(buffer.lineForRow(6)).toBe "# right = []"
expect(buffer.lineForRow(7)).toBe "# "
languageMode.toggleLineCommentsInRange([[4, 5], [5, 8]])
languageMode.toggleLineCommentsForBufferRows(4, 5)
expect(buffer.lineForRow(4)).toBe " pivot = items.shift()"
expect(buffer.lineForRow(5)).toBe " left = []"
expect(buffer.lineForRow(6)).toBe "# right = []"