mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Merge branch 'yomybaby-patch-1'
This commit is contained in:
@@ -85,80 +85,6 @@ describe "TextEditor", ->
|
||||
expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBe 1
|
||||
expect(editor.tokenizedLineForScreenRow(1).tokens.length).toBe 2 # sof tab
|
||||
|
||||
describe "when the editor is constructed with an initialLine option", ->
|
||||
it "positions the cursor on the specified line", ->
|
||||
editor = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialLine: 5).then (o) -> editor = o
|
||||
|
||||
runs ->
|
||||
expect(editor.getLastCursor().getBufferPosition().row).toEqual 5
|
||||
expect(editor.getLastCursor().getBufferPosition().column).toEqual 0
|
||||
|
||||
describe "when the editor is constructed with an initialColumn option", ->
|
||||
it "positions the cursor on the specified column", ->
|
||||
editor = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: 8).then (o) -> editor = o
|
||||
|
||||
runs ->
|
||||
expect(editor.getLastCursor().getBufferPosition().row).toEqual 0
|
||||
expect(editor.getLastCursor().getBufferPosition().column).toEqual 8
|
||||
|
||||
describe "when the editor is reopened with an initialLine option", ->
|
||||
it "positions the cursor on the specified line", ->
|
||||
editor = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialLine: 5).then (o) -> editor = o
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialLine: 4).then (o) -> editor = o
|
||||
|
||||
runs ->
|
||||
expect(editor.getLastCursor().getBufferPosition().row).toEqual 4
|
||||
expect(editor.getLastCursor().getBufferPosition().column).toEqual 0
|
||||
|
||||
describe "when the editor is reopened with an initialColumn option", ->
|
||||
it "positions the cursor on the specified column", ->
|
||||
editor = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: 8).then (o) -> editor = o
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: 7).then (o) -> editor = o
|
||||
|
||||
runs ->
|
||||
expect(editor.getLastCursor().getBufferPosition().row).toEqual 0
|
||||
expect(editor.getLastCursor().getBufferPosition().column).toEqual 7
|
||||
|
||||
it "ignores non-numeric initialLine and initialColumn options", ->
|
||||
[editor1, editor2, editor3] = []
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: 8, initialLine: NaN).then (o) -> editor1 = o
|
||||
|
||||
runs ->
|
||||
expect(editor1.getLastCursor().getBufferPosition().row).toEqual 0
|
||||
expect(editor1.getLastCursor().getBufferPosition().column).toEqual 8
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: NaN, initialLine: 3).then (o) -> editor2 = o
|
||||
|
||||
runs ->
|
||||
expect(editor2.getLastCursor().getBufferPosition().row).toEqual 3
|
||||
expect(editor2.getLastCursor().getBufferPosition().column).toEqual 0
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.less', initialColumn: NaN, initialLine: NaN).then (o) -> editor3 = o
|
||||
|
||||
runs ->
|
||||
expect(editor3.getLastCursor().getBufferPosition().row).toEqual 3
|
||||
expect(editor3.getLastCursor().getBufferPosition().column).toEqual 0
|
||||
|
||||
describe ".copy()", ->
|
||||
it "returns a different edit session with the same initial state", ->
|
||||
editor.setSelectedBufferRange([[1, 2], [3, 4]])
|
||||
|
||||
@@ -225,6 +225,44 @@ describe "Workspace", ->
|
||||
expect(workspace.paneContainer.root.children[0]).toBe pane1
|
||||
expect(workspace.paneContainer.root.children[1]).toBe pane4
|
||||
|
||||
describe "when an initialLine and initialColumn are specified", ->
|
||||
it "moves the cursor to the indicated location", ->
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: 1, initialColumn: 5)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [1, 5]
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: 2, initialColumn: 4)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [2, 4]
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: 0, initialColumn: 0)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: NaN, initialColumn: 4)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [0, 4]
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: 2, initialColumn: NaN)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [2, 0]
|
||||
|
||||
waitsForPromise ->
|
||||
workspace.open('a', initialLine: Infinity, initialColumn: Infinity)
|
||||
|
||||
runs ->
|
||||
expect(workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [2, 11]
|
||||
|
||||
describe "when the file is over 2MB", ->
|
||||
it "opens the editor with largeFileMode: true", ->
|
||||
spyOn(fs, 'getSizeSync').andReturn 2 * 1048577 # 2MB
|
||||
|
||||
@@ -468,11 +468,11 @@ class Workspace extends Model
|
||||
pane.activate() if activatePane
|
||||
|
||||
initialLine = initialColumn = 0
|
||||
if Number.isFinite(options.initialLine)
|
||||
unless Number.isNaN(options.initialLine)
|
||||
initialLine = options.initialLine
|
||||
if Number.isFinite(options.initialColumn)
|
||||
unless Number.isNaN(options.initialColumn)
|
||||
initialColumn = options.initialColumn
|
||||
if initialLine > 0 or initialColumn > 0
|
||||
if initialLine >= 0 or initialColumn >= 0
|
||||
item.setCursorBufferPosition?([initialLine, initialColumn])
|
||||
|
||||
index = pane.getActiveItemIndex()
|
||||
|
||||
Reference in New Issue
Block a user