From dc5d25f2b7c9231e1812b7abd27a421f370a3cf1 Mon Sep 17 00:00:00 2001 From: quorafind <951011105@qq.com> Date: Wed, 17 Jan 2024 14:14:07 +0800 Subject: [PATCH] fix: cannot close via hotkey --- src/floatSearchIndex.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/floatSearchIndex.ts b/src/floatSearchIndex.ts index f24e636..e25bf1f 100644 --- a/src/floatSearchIndex.ts +++ b/src/floatSearchIndex.ts @@ -81,6 +81,8 @@ const initSearchViewWithLeaf = async (app: App, type: PaneType | 'sidebar', stat state: state }); + console.log(leaf.view); + setTimeout(() => { const inputEl = leaf.containerEl.getElementsByTagName("input")[0]; inputEl.focus(); @@ -371,6 +373,10 @@ export default class FloatSearchPlugin extends Plugin { onOpen(old) { return function () { old.call(this); + (this.scope as Scope).register(['Mod'], 'w', () => { + this.leaf?.detach(); + }); + const viewSwitchEl = createDiv({cls: "float-search-view-switch"}); const targetEl = this.filterSectionToggleEl; const viewSwitchButton = new ExtraButtonComponent(viewSwitchEl); @@ -482,6 +488,7 @@ export default class FloatSearchPlugin extends Plugin { const existingLeaf = this.app.workspace.getLeavesOfType("search"); switch (type) { case "window": + // @ts-ignore const isExistingWindowLeaf = existingLeaf.find((leaf) => leaf.parentSplit.parent.type === "window"); if (isExistingWindowLeaf) { this.app.workspace.revealLeaf(isExistingWindowLeaf); @@ -491,7 +498,9 @@ export default class FloatSearchPlugin extends Plugin { break; case "tab": case "split": + // @ts-ignore const isExistingLeaf = existingLeaf.find((leaf) => !leaf.parentSplit.parent.side); + console.log(isExistingLeaf); if (isExistingLeaf) { this.app.workspace.revealLeaf(isExistingLeaf); return;