diff --git a/src/main.ts b/src/main.ts index b589d3e..187a28e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -71,6 +71,8 @@ declare global { addResources: SettingsSearch["addResources"]; removeResources: SettingsSearch["removeResources"]; removeTabResources: SettingsSearch["removeTabResources"]; + isBuildingResourcesForTab: SettingsSearch["isBuildingResourcesForTab"]; + getShownResult: SettingsSearch["getShownResult"]; }; } } @@ -104,7 +106,9 @@ export default class SettingsSearch extends Plugin { (window["SettingsSearch"] = { addResources: this.addResources.bind(this), removeResources: this.removeResources.bind(this), - removeTabResources: this.removeTabResources.bind(this) + removeTabResources: this.removeTabResources.bind(this), + isBuildingResourcesForTab: this.isBuildingResourcesForTab.bind(this), + getShownResult: this.getShownResult.bind(this), }) && this.register(() => delete window["SettingsSearch"]); this.app.workspace.onLayoutReady(async () => { @@ -283,8 +287,14 @@ export default class SettingsSearch extends Plugin { this.resources = this.resources.filter((t) => t.tab != tab); this.removeResourcesFromCache(removing); } + tabCached: SettingTab | null = null; + isBuildingResourcesForTab(tab: SettingTab) { + return tab === this.tabCached; + } async getTabResources(tab: SettingTab) { + this.tabCached = tab; await tab.display(); + this.tabCached = null; const settings = tab.containerEl.querySelectorAll( ".setting-item:not(.setting-item-header)" ); @@ -573,6 +583,10 @@ export default class SettingsSearch extends Plugin { } } + shownResult: Resource | null = null; + getShownResult() { + return this.shownResult; + } showResult(result: Resource) { this.search.setValue(""); const tab = @@ -583,7 +597,10 @@ export default class SettingsSearch extends Plugin { return; } + this.shownResult = result; this.app.setting.openTabById(tab.id); + this.shownResult = null; + this.app.keymap.popScope(this.scope); this.detach();