Skip to content

Commit

Permalink
Fix 1.x view headers on new/empty tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
pjeby committed Jan 11, 2023
1 parent d4d991a commit 34d1c86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Quick Explorer",
"author": "PJ Eby",
"authorUrl": "https://github.com/pjeby",
"version": "0.2.7",
"version": "0.2.8",
"description": "Perform file explorer operations (and see your current file path) from the title bar, using the mouse or keyboard",
"minAppVersion": "0.15.9",
"isDesktopOnly": true
Expand Down
11 changes: 6 additions & 5 deletions src/Explorer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, FileView, requireApiVersion, TAbstractFile, TFile, TFolder, WorkspaceLeaf } from "./obsidian";
import { App, FileView, requireApiVersion, TAbstractFile, TFile, TFolder, View, WorkspaceLeaf } from "./obsidian";
import { list, el, mount, unmount } from "redom";
import { ContextMenu } from "./ContextMenu";
import { FolderMenu } from "./FolderMenu";
Expand Down Expand Up @@ -127,7 +127,7 @@ export class Explorer extends PerWindowComponent {
visibleCrumb(opener: HTMLElement) {
let crumb = explorableCrumb(this, opener);
if (!opener.isShown()) {
const altOpener = app.workspace.getActiveViewOfType(FileView).containerEl.find(
const altOpener = app.workspace.getActiveViewOfType(View).containerEl.find(
".view-header .view-header-title-parent"
);
if (altOpener?.isShown()) {
Expand Down Expand Up @@ -230,12 +230,13 @@ function tabCrumb(opener: HTMLElement) {
const leafEl = opener.matchParent(".workspace-leaf");
let leaf: WorkspaceLeaf, crumb: Breadcrumb;
app.workspace.iterateAllLeaves(l => l.containerEl === leafEl && (leaf = l) && true);
const file = (leaf?.view as FileView)?.file;
const root = app.vault.getAbstractFileByPath("/");
const file = (leaf?.view as FileView)?.file ?? root;
const tree = hierarchy(file);
const parent = opener.matchParent(".view-header-title-parent");
crumb = new Breadcrumb(crumbs, parent as HTMLElement, tree.shift().file, onOpen, onClose);
crumb = new Breadcrumb(crumbs, parent as HTMLElement, tree.shift()?.file ?? root, onOpen, onClose);
for (const el of parent.findAll(".view-header-breadcrumb")) {
new Breadcrumb(crumbs, el, tree.shift().file, onOpen, onClose);
new Breadcrumb(crumbs, el, tree.shift()?.file ?? root, onOpen, onClose);
if (el === opener) crumb = crumbs[crumbs.length-1];
}
return crumb;
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"0.2.7": "0.15.9",
"0.2.8": "0.15.9",
"0.1.41": "0.15.9",
"0.1.37": "0.14.5",
"0.1.23": "0.14.2",
Expand Down

0 comments on commit 34d1c86

Please sign in to comment.