feat: apply colors to active leaf on file change and simplify color application logic

This commit is contained in:
Rafael-Ordaz_nabors 2026-06-08 16:45:51 -05:00
parent 5557125ceb
commit 2f8d6c5436

12
main.ts
View file

@ -56,6 +56,13 @@ export default class ColorTabPlugin extends Plugin {
)
);
// Clear/apply color when a new file is loaded into any leaf
this.registerEvent(
this.app.workspace.on("active-leaf-change", () =>
this.applyAllColors()
)
);
this.app.workspace.onLayoutReady(() => this.applyAllColors());
}
@ -122,9 +129,8 @@ export default class ColorTabPlugin extends Plugin {
applyAllColors() {
this.app.workspace.iterateAllLeaves((leaf) => {
const path = this.getFilePath(leaf);
if (path && this.settings.fileColors[path]) {
this.applyColorToLeaf(leaf, this.settings.fileColors[path]);
}
const color = path ? (this.settings.fileColors[path] ?? null) : null;
this.applyColorToLeaf(leaf, color);
});
}