mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Ignore NaN coordinates passed to workspace.open
This commit is contained in:
@@ -135,6 +135,30 @@ describe "TextEditor", ->
|
||||
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]])
|
||||
|
||||
@@ -456,8 +456,15 @@ class Workspace extends Model
|
||||
@itemOpened(item)
|
||||
pane.activateItem(item)
|
||||
pane.activate() if activatePane
|
||||
if options.initialLine? or options.initialColumn?
|
||||
item.setCursorBufferPosition?([options.initialLine, options.initialColumn])
|
||||
|
||||
initialLine = initialColumn = 0
|
||||
if Number.isFinite(options.initialLine)
|
||||
initialLine = options.initialLine
|
||||
if Number.isFinite(options.initialColumn)
|
||||
initialColumn = options.initialColumn
|
||||
if initialLine > 0 or initialColumn > 0
|
||||
item.setCursorBufferPosition?([initialLine, initialColumn])
|
||||
|
||||
index = pane.getActiveItemIndex()
|
||||
@emit "uri-opened" if includeDeprecatedAPIs
|
||||
@emitter.emit 'did-open', {uri, pane, item, index}
|
||||
|
||||
Reference in New Issue
Block a user