Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Prevent multiple instances of tree-view being opened #1283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shadow-light
Copy link

Description of the Change

Currently tree-view opens itself with a call to atom.workspace.open which by default: "only the active pane will be searched for an existing item"

When the left dock is split, only the bottom pane of that dock is searched, and if tree-view already exists in another pane then two instances of tree-view are opened. Initially the duplicate instance is blank, but upon restarting atom it causes atom to crash with Error: The workspace can only contain one instance of item.

Alternate Designs

None

Benefits

Atom doesn't crash

Possible Drawbacks

None

Applicable Issues

This should fix:

@winstliu
Copy link
Contributor

Reproduction steps:

  1. Have the Tree View open in the left dock
  2. Focus the left dock and execute pane:split-down
  3. Move a dock item into the lower split (for example, the Git dock)
  4. Focus the lower split and reload Atom
  5. Two "Project"s should appear
  6. Reload Atom
  7. 💥

@winstliu
Copy link
Contributor

@shadow-light can you add a regression test for this?

@shadow-light
Copy link
Author

Sure, I can try. Can you point me to a similar one that I can learn from?

@winstliu
Copy link
Contributor

@shadow-light I took a look at what tests we have now for package activation and it looks like there's nothing similar. If you'd prefer, I can try adding the test for you. Otherwise, here's what I'm thinking:

The tree-view setup is done here. You can probably add a test in the "package activation" section that gets the active pane of the dock and splits it. Then require tree-view and atom.workspace.open it in the new split. The active pane item should be undefined.

@shadow-light
Copy link
Author

If you don't mind adding it for me that would be great. Mainly because I'm not too familiar with Atom's API and already couldn't figure out how to do some things in my init script 😆

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants