* 处理文件重命名 * @param oldPath 旧路径 * @param newPath 新路径
(oldPath: string, newPath: string)
| 151 | * @param newPath 新路径 |
| 152 | */ |
| 153 | async handleFileRename(oldPath: string, newPath: string): Promise<void> { |
| 154 | const oldStoragePath = this.getStoragePathForFile(oldPath); |
| 155 | const newStoragePath = this.getStoragePathForFile(newPath); |
| 156 | |
| 157 | try { |
| 158 | // 检查旧文件是否存在 |
| 159 | const content = await this.app.vault.adapter.read(oldStoragePath); |
| 160 | |
| 161 | // 写入新位置 |
| 162 | await this.app.vault.adapter.write(newStoragePath, content); |
| 163 | |
| 164 | // 删除旧文件 |
| 165 | await this.app.vault.adapter.remove(oldStoragePath); |
| 166 | |
| 167 | // 更新映射 |
| 168 | this.fileMappingStore.delete(oldPath); |
| 169 | await this.saveFileMapping(); |
| 170 | } catch { |
| 171 | // 旧文件可能不存在,忽略错误 |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * 获取所有高亮文件列表 |
nothing calls this directly
no test coverage detected