mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add specs for initialLine and initialColumn, simplify implementation
This commit is contained in:
@@ -225,6 +225,26 @@ 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]
|
||||
|
||||
describe "when the file is over 2MB", ->
|
||||
it "opens the editor with largeFileMode: true", ->
|
||||
spyOn(fs, 'getSizeSync').andReturn 2 * 1048577 # 2MB
|
||||
|
||||
@@ -472,7 +472,7 @@ class Workspace extends Model
|
||||
initialLine = options.initialLine
|
||||
if Number.isFinite(options.initialColumn)
|
||||
initialColumn = options.initialColumn
|
||||
if initialLine > 0 or initialColumn > 0 or options.initialLine? or options.initialColumn?
|
||||
if initialLine >= 0 or initialColumn >= 0
|
||||
item.setCursorBufferPosition?([initialLine, initialColumn])
|
||||
|
||||
index = pane.getActiveItemIndex()
|
||||
|
||||
Reference in New Issue
Block a user