mirror of
https://github.com/rordaz/ColorTab.git
synced 2026-07-22 07:48:53 +00:00
fix: restore colors for deferred tabs on startup
This commit is contained in:
parent
60e227a959
commit
cf46b2b60f
1 changed files with 10 additions and 4 deletions
14
main.ts
14
main.ts
|
|
@ -287,15 +287,21 @@ export default class ColorTabPlugin extends Plugin {
|
|||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private getFilePath(leaf: WorkspaceLeaf): string | null {
|
||||
// Try to get file from view first (most common), then from leaf directly
|
||||
// Loaded views expose their file directly.
|
||||
const fileFromView = (leaf.view as unknown as { file?: { path: string } })
|
||||
?.file;
|
||||
if (fileFromView?.path) return fileFromView.path;
|
||||
|
||||
// Fallback for view types like excalidraw that may store file directly on leaf
|
||||
|
||||
// Excalidraw can store the file directly on the leaf.
|
||||
const fileFromLeaf = (leaf as unknown as { file?: { path: string } })
|
||||
?.file;
|
||||
return fileFromLeaf?.path ?? null;
|
||||
if (fileFromLeaf?.path) return fileFromLeaf.path;
|
||||
|
||||
// Background tabs can be deferred after startup, leaving view.file unset.
|
||||
const fileFromState = leaf.getViewState().state?.file;
|
||||
return typeof fileFromState === "string" && fileFromState.length > 0
|
||||
? fileFromState
|
||||
: null;
|
||||
}
|
||||
|
||||
private isColorableLeaf(leaf: WorkspaceLeaf): boolean {
|
||||
|
|
|
|||
Loading…
Reference in a new issue