diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 35585479b8d..90883d2a1d2 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -471,6 +471,27 @@ describe "Workspace", -> workspace.open("bar://baz").then (item) -> expect(item).toEqual {bar: "bar://baz"} + it "adds the file to the application's recent documents list", -> + spyOn(atom.applicationDelegate, 'addRecentDocument') + + waitsForPromise -> + workspace.open() + + runs -> + expect(atom.applicationDelegate.addRecentDocument).not.toHaveBeenCalled() + + waitsForPromise -> + workspace.open('something://a/url') + + runs -> + expect(atom.applicationDelegate.addRecentDocument).not.toHaveBeenCalled() + + waitsForPromise -> + workspace.open(__filename) + + runs -> + expect(atom.applicationDelegate.addRecentDocument).toHaveBeenCalledWith(__filename) + it "notifies ::onDidAddTextEditor observers", -> absolutePath = require.resolve('./fixtures/dir/a') newEditorHandler = jasmine.createSpy('newEditorHandler') diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index de52fe55cf2..e8d656a4372 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -885,8 +885,6 @@ class AtomEnvironment extends Model else @project.addPath(pathToOpen) - @applicationDelegate.addRecentDocument(pathToOpen) - unless fs.isDirectorySync(pathToOpen) @workspace?.open(pathToOpen, {initialLine, initialColumn}) diff --git a/src/workspace.coffee b/src/workspace.coffee index 07e69cdcf82..7983f7aa6dd 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -1,4 +1,5 @@ _ = require 'underscore-plus' +url = require 'url' path = require 'path' {join} = path {Emitter, Disposable, CompositeDisposable} = require 'event-kit' @@ -409,6 +410,11 @@ class Workspace extends Model split = options.split uri = @project.resolvePath(uri) + # Avoid adding URLs as recent documents to work-around this Spotlight crash: + # https://github.com/atom/atom/issues/10071 + if uri? and not url.parse(uri).protocol? + @applicationDelegate.addRecentDocument(uri) + pane = @paneContainer.paneForURI(uri) if searchAllPanes pane ?= switch split when 'left'