diff --git a/packages/core/src/browser/widgets/widget.ts b/packages/core/src/browser/widgets/widget.ts
index 9a71b96074208..db2b6f053b26d 100644
--- a/packages/core/src/browser/widgets/widget.ts
+++ b/packages/core/src/browser/widgets/widget.ts
@@ -24,6 +24,7 @@ import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys';
import PerfectScrollbar from 'perfect-scrollbar';
import { PreviewableWidget } from '../widgets/previewable-widget';
+import { Slot } from '@phosphor/signaling';
decorate(injectable(), Widget);
decorate(unmanaged(), Widget, 0);
@@ -364,23 +365,37 @@ function waitForVisible(widget: Widget, visible: boolean, attached?: boolean): P
});
}
+const pinnedTitles = new Map
, [boolean, Slot]>();
+
export function isPinned(title: Title): boolean {
const pinnedState = !title.closable && title.className.includes(PINNED_CLASS);
return pinnedState;
}
-export function unpin(title: Title): void {
- title.closable = true;
- title.className = title.className.replace(PINNED_CLASS, '').trim();
-}
-
export function pin(title: Title): void {
+ const l = () => {
+ pinnedTitles.delete(title);
+ };
+ pinnedTitles.set(title, [title.closable, l]);
+ title.owner.disposed.connect(l);
title.closable = false;
if (!title.className.includes(PINNED_CLASS)) {
title.className += ` ${PINNED_CLASS}`;
}
}
+export function unpin(title: Title): void {
+ const entry = pinnedTitles.get(title);
+ if (entry) {
+ title.owner.disposed.disconnect(entry[1]);
+ title.closable = entry[0];
+ pinnedTitles.delete(title);
+ } else {
+ title.closable = true;
+ }
+ title.className = title.className.replace(PINNED_CLASS, '').trim();
+}
+
export function isLocked(title: Title): boolean {
return title.className.includes(LOCKED_CLASS);
}