mirror of
https://github.com/rordaz/ColorTab.git
synced 2026-07-22 07:48:53 +00:00
feat: apply colors to active leaf on file change and simplify color application logic
This commit is contained in:
parent
5557125ceb
commit
2f8d6c5436
1 changed files with 9 additions and 3 deletions
12
main.ts
12
main.ts
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue