mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge remote-tracking branch 'origin/master' into win-specs
This commit is contained in:
@@ -1326,7 +1326,7 @@ describe "EditSession", ->
|
||||
expect(cursor2.getBufferPosition()).toEqual [8,0]
|
||||
|
||||
describe ".insertNewlineBelow()", ->
|
||||
xdescribe "when the operation is undone", ->
|
||||
describe "when the operation is undone", ->
|
||||
it "places the cursor back at the previous location", ->
|
||||
editSession.setCursorBufferPosition([0,2])
|
||||
editSession.insertNewlineBelow()
|
||||
@@ -1334,8 +1334,8 @@ describe "EditSession", ->
|
||||
editSession.undo()
|
||||
expect(editSession.getCursorBufferPosition()).toEqual [0,2]
|
||||
|
||||
xit "inserts a newline below the cursor's current line, autoindents it, and moves the cursor to the end of the line", ->
|
||||
editSession.setAutoIndent(true)
|
||||
it "inserts a newline below the cursor's current line, autoindents it, and moves the cursor to the end of the line", ->
|
||||
config.set("editor.autoIndent", true)
|
||||
editSession.insertNewlineBelow()
|
||||
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
|
||||
expect(buffer.lineForRow(1)).toBe " "
|
||||
@@ -1353,13 +1353,16 @@ describe "EditSession", ->
|
||||
|
||||
describe "when the cursor is not on the first line", ->
|
||||
it "inserts a newline above the current line and moves the cursor to the inserted line", ->
|
||||
editSession.setCursorBufferPosition([3])
|
||||
editSession.setCursorBufferPosition([3,4])
|
||||
editSession.insertNewlineAbove()
|
||||
expect(editSession.getCursorBufferPosition()).toEqual [3,0]
|
||||
expect(editSession.lineForBufferRow(3)).toBe ''
|
||||
expect(editSession.lineForBufferRow(4)).toBe ' var pivot = items.shift(), current, left = [], right = [];'
|
||||
expect(editSession.buffer.getLineCount()).toBe 14
|
||||
|
||||
editSession.undo()
|
||||
expect(editSession.getCursorBufferPosition()).toEqual [3,4]
|
||||
|
||||
describe ".backspace()", ->
|
||||
describe "when there is a single cursor", ->
|
||||
changeScreenRangeHandler = null
|
||||
@@ -2062,7 +2065,7 @@ describe "EditSession", ->
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(buffer.lineForRow(10)).toBe " "
|
||||
|
||||
xdescribe ".undo() and .redo()", ->
|
||||
describe ".undo() and .redo()", ->
|
||||
it "undoes/redoes the last change", ->
|
||||
editSession.insertText("foo")
|
||||
editSession.undo()
|
||||
@@ -2110,7 +2113,7 @@ describe "EditSession", ->
|
||||
editSession.redo()
|
||||
expect(editSession.getSelectedBufferRanges()).toEqual [[[1, 6], [1, 6]], [[1, 18], [1, 18]]]
|
||||
|
||||
it "restores folds after undo and redo", ->
|
||||
xit "restores folds after undo and redo", ->
|
||||
editSession.foldBufferRow(1)
|
||||
editSession.setSelectedBufferRange([[1, 0], [10, Infinity]], preserveFolds: true)
|
||||
expect(editSession.isFoldedAtBufferRow(1)).toBeTruthy()
|
||||
@@ -2133,27 +2136,26 @@ describe "EditSession", ->
|
||||
expect(editSession.isFoldedAtBufferRow(1)).toBeFalsy()
|
||||
expect(editSession.isFoldedAtBufferRow(2)).toBeTruthy()
|
||||
|
||||
xdescribe ".transact([fn])", ->
|
||||
describe "when called without a function", ->
|
||||
it "restores the selection when the transaction is undone/redone", ->
|
||||
buffer.setText('1234')
|
||||
editSession.setSelectedBufferRange([[0, 1], [0, 3]])
|
||||
editSession.transact()
|
||||
describe "begin/commitTransaction()", ->
|
||||
it "restores the selection when the transaction is undone/redone", ->
|
||||
buffer.setText('1234')
|
||||
editSession.setSelectedBufferRange([[0, 1], [0, 3]])
|
||||
editSession.beginTransaction()
|
||||
|
||||
editSession.delete()
|
||||
editSession.moveCursorToEndOfLine()
|
||||
editSession.insertText('5')
|
||||
expect(buffer.getText()).toBe '145'
|
||||
editSession.delete()
|
||||
editSession.moveCursorToEndOfLine()
|
||||
editSession.insertText('5')
|
||||
expect(buffer.getText()).toBe '145'
|
||||
|
||||
editSession.commit()
|
||||
editSession.commitTransaction()
|
||||
|
||||
editSession.undo()
|
||||
expect(buffer.getText()).toBe '1234'
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [0, 3]]
|
||||
editSession.undo()
|
||||
expect(buffer.getText()).toBe '1234'
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [0, 3]]
|
||||
|
||||
editSession.redo()
|
||||
expect(buffer.getText()).toBe '145'
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[0, 3], [0, 3]]
|
||||
editSession.redo()
|
||||
expect(buffer.getText()).toBe '145'
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[0, 3], [0, 3]]
|
||||
|
||||
describe "when the buffer is changed (via its direct api, rather than via than edit session)", ->
|
||||
it "moves the cursor so it is in the same relative position of the buffer", ->
|
||||
@@ -2274,7 +2276,7 @@ describe "EditSession", ->
|
||||
expect(buffer.lineForRow(6)).toBe(line7)
|
||||
expect(buffer.getLineCount()).toBe(count - 1)
|
||||
|
||||
xdescribe "when the line being deleted preceeds a fold, and the command is undone", ->
|
||||
describe "when the line being deleted preceeds a fold, and the command is undone", ->
|
||||
it "restores the line and preserves the fold", ->
|
||||
editSession.setCursorBufferPosition([4])
|
||||
editSession.foldCurrentRow()
|
||||
|
||||
@@ -1656,6 +1656,7 @@ describe "Editor", ->
|
||||
|
||||
describe "when soft-wrap is enabled", ->
|
||||
beforeEach ->
|
||||
jasmine.unspy(window, 'setTimeout')
|
||||
editSession.setSoftWrap(true)
|
||||
editor.attachToDom()
|
||||
setEditorHeightInLines(editor, 20)
|
||||
@@ -1735,6 +1736,19 @@ describe "Editor", ->
|
||||
expect(otherEditor.setWidthInChars).toHaveBeenCalled()
|
||||
otherEditor.remove()
|
||||
|
||||
describe "when the editor's width changes", ->
|
||||
it "updates the width in characters on the edit session", ->
|
||||
previousSoftWrapColumn = editSession.getSoftWrapColumn()
|
||||
|
||||
spyOn(editor, 'setWidthInChars').andCallThrough()
|
||||
editor.width(editor.width() / 2)
|
||||
|
||||
waitsFor ->
|
||||
editor.setWidthInChars.callCount > 0
|
||||
|
||||
runs ->
|
||||
expect(editSession.getSoftWrapColumn()).toBeLessThan previousSoftWrapColumn
|
||||
|
||||
describe "gutter rendering", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(heightInLines: 5.5)
|
||||
@@ -2096,42 +2110,42 @@ describe "Editor", ->
|
||||
expect(editor.getCursorBufferPosition()).toEqual [3, 0]
|
||||
|
||||
describe "when a selection starts/stops intersecting a fold", ->
|
||||
it "adds/removes the 'selected' class to the fold's line element and hides the cursor if it is on the fold line", ->
|
||||
it "adds/removes the 'fold-selected' class to the fold's line element and hides the cursor if it is on the fold line", ->
|
||||
editor.createFold(2, 4)
|
||||
|
||||
editor.setSelectedBufferRange([[1, 0], [2, 0]], preserveFolds: true, isReversed: true)
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.fold-selected')
|
||||
|
||||
editor.setSelectedBufferRange([[1, 0], [1, 1]], preserveFolds: true)
|
||||
expect(editor.lineElementForScreenRow(2)).not.toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).not.toMatchSelector('.fold.fold-selected')
|
||||
|
||||
editor.setSelectedBufferRange([[1, 0], [5, 0]], preserveFolds: true)
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.fold-selected')
|
||||
|
||||
editor.setCursorScreenPosition([3,0])
|
||||
expect(editor.lineElementForScreenRow(2)).not.toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).not.toMatchSelector('.fold.fold-selected')
|
||||
|
||||
editor.setCursorScreenPosition([2,0])
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.fold-selected')
|
||||
expect(editor.find('.cursor')).toBeHidden()
|
||||
|
||||
editor.setCursorScreenPosition([3,0])
|
||||
expect(editor.find('.cursor')).toBeVisible()
|
||||
|
||||
describe "when a selected fold is scrolled into view (and the fold line was not previously rendered)", ->
|
||||
it "renders the fold's line element with the 'selected' class", ->
|
||||
it "renders the fold's line element with the 'fold-selected' class", ->
|
||||
setEditorHeightInLines(editor, 5)
|
||||
editor.resetDisplay()
|
||||
|
||||
editor.createFold(2, 4)
|
||||
editor.setSelectedBufferRange([[1, 0], [5, 0]], preserveFolds: true)
|
||||
expect(editor.renderedLines.find('.fold.selected')).toExist()
|
||||
expect(editor.renderedLines.find('.fold.fold-selected')).toExist()
|
||||
|
||||
editor.scrollToBottom()
|
||||
expect(editor.renderedLines.find('.fold.selected')).not.toExist()
|
||||
expect(editor.renderedLines.find('.fold.fold-selected')).not.toExist()
|
||||
|
||||
editor.scrollTop(0)
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.selected')
|
||||
expect(editor.lineElementForScreenRow(2)).toMatchSelector('.fold.fold-selected')
|
||||
|
||||
describe "paging up and down", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -333,6 +333,28 @@ describe "RootView", ->
|
||||
expect(pane2.itemForUri('b')).not.toBeFalsy()
|
||||
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
|
||||
|
||||
it "handles split: left by opening to the left pane when necessary", ->
|
||||
rootView.openSingletonSync('b', split: 'right')
|
||||
pane2 = rootView.getActivePane()
|
||||
expect(pane2[0]).not.toBe pane1[0]
|
||||
|
||||
rootView.openSingletonSync('file1', split: 'left')
|
||||
|
||||
activePane = rootView.getActivePane()
|
||||
expect(activePane[0]).toBe pane1[0]
|
||||
|
||||
expect(pane1.itemForUri('file1')).toBeTruthy()
|
||||
expect(pane2.itemForUri('file1')).toBeFalsy()
|
||||
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
|
||||
|
||||
pane2.focus()
|
||||
expect(rootView.getActivePane()[0]).toBe pane2[0]
|
||||
|
||||
rootView.openSingletonSync('file1', split: 'left')
|
||||
activePane = rootView.getActivePane()
|
||||
expect(activePane[0]).toBe pane1[0]
|
||||
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
|
||||
|
||||
it "reuses the file when already open", ->
|
||||
rootView.openSync('b')
|
||||
rootView.openSingletonSync('b', split: 'right')
|
||||
|
||||
Reference in New Issue
Block a user