From 204cf6802749dd6eba0861cc7cf9df143946e1b2 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 6 Feb 2017 17:51:15 -0500 Subject: [PATCH 1/6] Open empty editor as a pending pane item --- spec/main-process/atom-application.test.js | 10 +++++++++- src/atom-environment.coffee | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 62fae82b3..f3085ab02 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -267,14 +267,22 @@ describe('AtomApplication', function () { const window1EditorTitle = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) + const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem()) + }) assert.equal(window1EditorTitle, 'untitled') + assert.notEqual(window1EditorPending, null) const window2 = atomApplication.openWithOptions(parseCommandLine([])) await focusWindow(window2) const window2EditorTitle = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) + const window2EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem()) + }) assert.equal(window2EditorTitle, 'untitled') + assert.notEqual(window2EditorPending, null) assert.deepEqual(atomApplication.windows, [window1, window2]) }) @@ -290,7 +298,7 @@ describe('AtomApplication', function () { const window1 = atomApplication.launch(parseCommandLine([])) await focusWindow(window1) - // wait a bit just to make sure we don't pass due to querying the render process before it loads + // wait a bit just to make sure we don't pass due to querying the render process before it loads await timeoutPromise(1000) const itemCount = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index a32c4424b..33b3bfe3a 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -777,7 +777,7 @@ class AtomEnvironment extends Model openInitialEmptyEditorIfNecessary: -> return unless @config.get('core.openEmptyEditorOnStart') if @getLoadSettings().initialPaths?.length is 0 and @workspace.getPaneItems().length is 0 - @workspace.open(null) + @workspace.open(null, {pending: true}) installUncaughtErrorHandler: -> @previousWindowErrorHandler = @window.onerror From 9249d0b58d41b62a0083888b2c934cc8d0f49507 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 23 Mar 2017 01:00:02 -0400 Subject: [PATCH 2/6] Send back a string --- spec/main-process/atom-application.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index f3085ab02..a3213b2c7 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -260,7 +260,7 @@ describe('AtomApplication', function () { await conditionPromise(async () => (await getTreeViewRootDirectories(reusedWindow)).length > 0) }) - it('opens a new window with a single untitled buffer when launched with no path, even if windows already exist', async function () { + it('opens a new window with a single untitled, pending buffer when launched with no path, even if windows already exist', async function () { const atomApplication = buildAtomApplication() const window1 = atomApplication.launch(parseCommandLine([])) await focusWindow(window1) @@ -268,10 +268,10 @@ describe('AtomApplication', function () { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { - sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem()) + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window1EditorTitle, 'untitled') - assert.notEqual(window1EditorPending, null) + assert.equal(window1EditorPending, 'untitled') const window2 = atomApplication.openWithOptions(parseCommandLine([])) await focusWindow(window2) @@ -279,10 +279,10 @@ describe('AtomApplication', function () { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) const window2EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { - sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem()) + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window2EditorTitle, 'untitled') - assert.notEqual(window2EditorPending, null) + assert.equal(window2EditorPending, 'untitled') assert.deepEqual(atomApplication.windows, [window1, window2]) }) From b35f2d35118ca855668836eb7cfb2997dd05c199 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 24 Mar 2017 00:12:20 -0400 Subject: [PATCH 3/6] Fix another spec --- spec/atom-environment-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/atom-environment-spec.coffee b/spec/atom-environment-spec.coffee index f178bbb6c..897879663 100644 --- a/spec/atom-environment-spec.coffee +++ b/spec/atom-environment-spec.coffee @@ -368,7 +368,7 @@ describe "AtomEnvironment", -> it "opens an empty buffer", -> spyOn(atom.workspace, 'open') atom.openInitialEmptyEditorIfNecessary() - expect(atom.workspace.open).toHaveBeenCalledWith(null) + expect(atom.workspace.open).toHaveBeenCalledWith(null, {pending: true}) describe "when there is already a buffer open", -> beforeEach -> From f62cad02b3ea2956380d1a8f0371fa801ed32be3 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Fri, 18 Jan 2019 21:40:35 -0500 Subject: [PATCH 4/6] Tabs to spaces Thanks @arcanemagus --- spec/main-process/atom-application.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 40802b436..8b4bf5277 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -83,22 +83,22 @@ describe('AtomApplication', function () { const window1EditorTitle = await evalInWebContents(window1.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { + const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window1EditorTitle, 'untitled') - assert.equal(window1EditorPending, 'untitled') + assert.equal(window1EditorPending, 'untitled') const window2 = atomApplication.openWithOptions(parseCommandLine([])) await window2.loadedPromise const window2EditorTitle = await evalInWebContents(window2.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window2EditorPending = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) { + const window2EditorPending = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window2EditorTitle, 'untitled') - assert.equal(window2EditorPending, 'untitled') + assert.equal(window2EditorPending, 'untitled') assert.deepEqual(atomApplication.getAllWindows(), [window2, window1]) }) @@ -126,14 +126,14 @@ describe('AtomApplication', function () { assert.lengthOf(appWindows2, 1) const [appWindow2] = appWindows2 await appWindow2.loadedPromise - const window2EditorTitle = await evalInWebContents(appWindow2.browserWindow.webContents, sendBackToMainProcess => { + const window2EditorTitle = await evalInWebContents(appWindow2.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window2EditorPending = await evalInWebContents(appWindow2.browserWindow.webContents, function (sendBackToMainProcess) { + const window2EditorPending = await evalInWebContents(appWindow2.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window2EditorTitle, 'untitled') - assert.equal(window2EditorPending, 'untitled') + assert.equal(window2EditorPending, 'untitled') }) it('does not open an empty editor if core.openEmptyEditorOnStart is false', async () => { From be6eae77c61e38ff819c9d1740c019d8b91397e1 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Fri, 18 Jan 2019 21:41:58 -0500 Subject: [PATCH 5/6] *actually* fix the indentation --- spec/main-process/atom-application.test.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 8b4bf5277..2885b0ff4 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -83,22 +83,22 @@ describe('AtomApplication', function () { const window1EditorTitle = await evalInWebContents(window1.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { + const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window1EditorTitle, 'untitled') - assert.equal(window1EditorPending, 'untitled') + assert.equal(window1EditorPending, 'untitled') const window2 = atomApplication.openWithOptions(parseCommandLine([])) await window2.loadedPromise const window2EditorTitle = await evalInWebContents(window2.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window2EditorPending = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) { - sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) + const window2EditorPending = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) { + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window2EditorTitle, 'untitled') - assert.equal(window2EditorPending, 'untitled') + assert.equal(window2EditorPending, 'untitled') assert.deepEqual(atomApplication.getAllWindows(), [window2, window1]) }) @@ -126,14 +126,14 @@ describe('AtomApplication', function () { assert.lengthOf(appWindows2, 1) const [appWindow2] = appWindows2 await appWindow2.loadedPromise - const window2EditorTitle = await evalInWebContents(appWindow2.browserWindow.webContents, sendBackToMainProcess => { + const window2EditorTitle = await evalInWebContents(appWindow2.browserWindow.webContents, sendBackToMainProcess => { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) - const window2EditorPending = await evalInWebContents(appWindow2.browserWindow.webContents, function (sendBackToMainProcess) { - sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) + const window2EditorPending = await evalInWebContents(appWindow2.browserWindow.webContents, function (sendBackToMainProcess) { + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window2EditorTitle, 'untitled') - assert.equal(window2EditorPending, 'untitled') + assert.equal(window2EditorPending, 'untitled') }) it('does not open an empty editor if core.openEmptyEditorOnStart is false', async () => { From af769c266b41fb0cd1c5e58c7212c0efe153d9ee Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Fri, 18 Jan 2019 21:42:27 -0500 Subject: [PATCH 6/6] One more time --- spec/main-process/atom-application.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 2885b0ff4..bca146c38 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -84,7 +84,7 @@ describe('AtomApplication', function () { sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle()) }) const window1EditorPending = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) { - sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) + sendBackToMainProcess(atom.workspace.getActivePane().getPendingItem().getTitle()) }) assert.equal(window1EditorTitle, 'untitled') assert.equal(window1EditorPending, 'untitled')