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

Commit 01791d1

Browse files
committed
Use _getStub to identify and unwrap stubs
1 parent 4a97e1a commit 01791d1

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

lib/atom/pane-item.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,32 @@ export default class PaneItem extends React.Component {
7474
// Listen for and adopt StubItems that are added after this component has
7575
// already been mounted.
7676
this.subs.add(this.props.workspace.onDidAddPaneItem(({item}) => {
77-
if (item.getRealItem && item.getRealItem() === null) {
78-
const match = this.state.uriPattern.matches(item.getURI());
79-
if (!match.ok()) {
80-
return;
81-
}
77+
if (!item._getStub) {
78+
return;
79+
}
80+
const stub = item._getStub();
8281

83-
const openItem = new OpenItem(match, item.getElement(), item);
84-
openItem.hydrateStub({
85-
copy: () => this.copyOpenItem(openItem),
86-
});
87-
if (this.props.className) {
88-
openItem.addClassName(this.props.className);
89-
}
90-
this.registerCloseListener(item, openItem);
82+
if (stub.getRealItem() !== null) {
83+
return;
84+
}
9185

92-
this.setState(prevState => ({
93-
currentlyOpen: [...prevState.currentlyOpen, openItem],
94-
}));
86+
const match = this.state.uriPattern.matches(item.getURI());
87+
if (!match.ok()) {
88+
return;
89+
}
90+
91+
const openItem = new OpenItem(match, stub.getElement(), stub);
92+
openItem.hydrateStub({
93+
copy: () => this.copyOpenItem(openItem),
94+
});
95+
if (this.props.className) {
96+
openItem.addClassName(this.props.className);
9597
}
98+
this.registerCloseListener(item, openItem);
99+
100+
this.setState(prevState => ({
101+
currentlyOpen: [...prevState.currentlyOpen, openItem],
102+
}));
96103
}));
97104

98105
for (const openItem of this.state.currentlyOpen) {

0 commit comments

Comments
 (0)