diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 4666177c6..636755346 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -954,7 +954,9 @@ describe "Workspace", -> @promise.then.apply(@promise, args) cancel: -> @cancelled = true - @hoistedReject() + # According to the spec for a DirectorySearcher, invoking `cancel()` should + # resolve the thenable rather than reject it. + @hoistedResolve() beforeEach -> fakeSearch = null diff --git a/src/workspace.coffee b/src/workspace.coffee index 6311cdd6d..afc197792 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -873,18 +873,16 @@ class Workspace extends Model isCancelled = false cancellablePromise = new Promise (resolve, reject) -> onSuccess = -> - resolve(null) - onFailure = -> if isCancelled resolve('cancelled') else - reject() - searchPromise.then(onSuccess, onFailure) + resolve(null) + searchPromise.then(onSuccess, reject) cancellablePromise.cancel = -> isCancelled = true - # Note that cancelling all (or actually, any) of the members of allSearches - # will cause searchPromise to reject, which will cause cancellablePromise to resolve - # in the desired way. + # Note that cancelling all of the members of allSearches will cause all of the searches + # to resolve, which causes searchPromise to resolve, which is ultimately what causes + # cancellablePromise to resolve. promise.cancel() for promise in allSearches # Although this method claims to return a `Promise`, the `ResultsPaneView.onSearch()`