Skip to content

Commit 61704d3

Browse files
committed
showing pane upon install and removing it from uninstall.
1 parent f1e11af commit 61704d3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export default class DictionaryPlugin extends Plugin {
3939
return new DictionaryView(leaf, this);
4040
});
4141

42+
if (this.app.workspace.getLeavesOfType(VIEW_TYPE).length == 0) {
43+
await this.app.workspace.getRightLeaf(false).setViewState({
44+
type: VIEW_TYPE,
45+
});
46+
}
47+
this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(VIEW_TYPE).first());
48+
4249
this.addCommand({
4350
id: 'dictionary-open-view',
4451
name: t('Open Dictionary View'),
@@ -126,6 +133,9 @@ export default class DictionaryPlugin extends Plugin {
126133
onunload(): void {
127134
console.log('unloading dictionary');
128135
this.app.workspace.off('editor-menu', this.handleContextMenuHelper)
136+
if (this.app.workspace.getLeavesOfType(VIEW_TYPE).length) {
137+
this.app.workspace.getLeavesOfType(VIEW_TYPE)[0].detach();
138+
}
129139
}
130140

131141
handleContextMenuHelper = (menu: Menu, editor: Editor, _: MarkdownView): void => {

0 commit comments

Comments
 (0)