* Handle file changes
(file: TFile, cache: unknown)
| 138 | * Handle file changes |
| 139 | */ |
| 140 | private handleFileChanged(file: TFile, cache: unknown): void { |
| 141 | const before = this.getFileRelationshipSignature(file.path); |
| 142 | |
| 143 | if (!this.isValidFile(file.path)) { |
| 144 | this.clearFileFromIndexes(file.path); |
| 145 | this.triggerIfFileRelationshipsChanged(file.path, before); |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | const frontmatter = this.getFrontmatterFromCache(cache) ?? this.getFrontmatterForFile(file); |
| 150 | this.updateCompletionState(file.path, frontmatter); |
| 151 | |
| 152 | if (!frontmatter) { |
| 153 | if (this.hasForwardRelationships(file.path)) { |
| 154 | this.clearForwardDependencies(file.path); |
| 155 | } |
| 156 | this.triggerIfFileRelationshipsChanged(file.path, before); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (!this.isTaskFileCallback(frontmatter)) { |
| 161 | if (this.hasForwardRelationships(file.path)) { |
| 162 | this.clearForwardDependencies(file.path); |
| 163 | } |
| 164 | this.triggerIfFileRelationshipsChanged(file.path, before); |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | const nextFingerprint = this.buildRelationshipFingerprint(frontmatter); |
| 169 | if (this.relationshipFingerprints.get(file.path) === nextFingerprint) { |
| 170 | this.triggerIfFileRelationshipsChanged(file.path, before); |
| 171 | return; |
| 172 | } |
| 173 | |
| 174 | // Re-index this task |
| 175 | // Only clear the forward dependencies (tasks this task depends on) |
| 176 | // Keep reverse dependencies intact - they'll be updated when other tasks change |
| 177 | this.clearForwardDependencies(file.path); |
| 178 | this.indexTaskFile(file.path, frontmatter); |
| 179 | this.triggerIfFileRelationshipsChanged(file.path, before); |
| 180 | } |
| 181 | |
| 182 | private triggerIfFileRelationshipsChanged(path: string, before: string): void { |
| 183 | if (this.getFileRelationshipSignature(path) !== before) { |
no test coverage detected