From 136a30f1808a8808fadce42fb9e3d9bdacde66fc Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 4 Sep 2015 10:23:40 -0400 Subject: [PATCH 1/3] Add a clarification about the usage of addOpener Documentation augmented with a note about the need of using fake protocol in order to invoke opener on a file already opened. See discussion at https://discuss.atom.io/t/difficulties-using-atom-workspace-addopener/20444 --- src/workspace.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/workspace.coffee b/src/workspace.coffee index 86e860fe2..55d6604ba 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -506,6 +506,12 @@ class Workspace extends Model # # Returns a {Disposable} on which `.dispose()` can be called to remove the # opener. + # + # Note that the opener will be called if and only if the URI is not already open + # in the current pane. The searchAllPanes flag expands the search from the + # current pane to all panes. If the file path is converted from a standard path, + # e.g. /foo/bar/baz.html, to a URI with a fake protocol, e.g. custom://foo/bar/baz.html, + # it wouldn't conflict and the opener will be invoked. addOpener: (opener) -> if includeDeprecatedAPIs packageName = @getCallingPackageName() From 2c7be877c6475733fbeaa7ffc255ca388b4cf92a Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Fri, 4 Sep 2015 13:28:19 -0400 Subject: [PATCH 2/3] Update note explaining the usage of the protocol --- src/workspace.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 55d6604ba..82d070c1c 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -509,9 +509,12 @@ class Workspace extends Model # # Note that the opener will be called if and only if the URI is not already open # in the current pane. The searchAllPanes flag expands the search from the - # current pane to all panes. If the file path is converted from a standard path, - # e.g. /foo/bar/baz.html, to a URI with a fake protocol, e.g. custom://foo/bar/baz.html, - # it wouldn't conflict and the opener will be invoked. + # current pane to all panes. If you wish to open a view of a different type for + # a file that is already open, consider changing the protocol of the URI. For + # example, perhaps you wish to preview a rendered version of the file /foo/bar/baz.quux + # that is already open in a text editor view. You could signal this by calling + # {Workspace::open} on the URI quux-preview://foo/bar/baz.quux. Then your opener + # can check the protocol for quux-preview and only handle those URIs that match. addOpener: (opener) -> if includeDeprecatedAPIs packageName = @getCallingPackageName() From f2a1b69a347d4bff95fb5fade547c6d31b28c912 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Sat, 5 Sep 2015 14:24:07 -0400 Subject: [PATCH 3/3] Add backticks around URLs for style consistency --- src/workspace.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 82d070c1c..ee7ccdf49 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -511,9 +511,9 @@ class Workspace extends Model # in the current pane. The searchAllPanes flag expands the search from the # current pane to all panes. If you wish to open a view of a different type for # a file that is already open, consider changing the protocol of the URI. For - # example, perhaps you wish to preview a rendered version of the file /foo/bar/baz.quux + # example, perhaps you wish to preview a rendered version of the file `/foo/bar/baz.quux` # that is already open in a text editor view. You could signal this by calling - # {Workspace::open} on the URI quux-preview://foo/bar/baz.quux. Then your opener + # {Workspace::open} on the URI `quux-preview://foo/bar/baz.quux`. Then your opener # can check the protocol for quux-preview and only handle those URIs that match. addOpener: (opener) -> if includeDeprecatedAPIs