feat: 优化代码变更面板样式和交互
- 优化变更面板和 diff 视图样式 - 新增全部采纳和全部拒绝按钮 - 修复删除文件的变更追踪和采纳逻辑 - 整个标题栏可点击展开/收起 - 增强视觉效果和用户体验
This commit is contained in:
@ -143,7 +143,16 @@ class ChangeTrackerService {
|
||||
}
|
||||
|
||||
const absolutePath = path.join(workspaceFolder.uri.fsPath, change.filePath);
|
||||
await fs.promises.writeFile(absolutePath, change.newContent, 'utf-8');
|
||||
|
||||
// 如果是删除操作,删除文件
|
||||
if (change.changeType === 'delete') {
|
||||
if (fs.existsSync(absolutePath)) {
|
||||
await fs.promises.unlink(absolutePath);
|
||||
}
|
||||
} else {
|
||||
// 创建或修改文件
|
||||
await fs.promises.writeFile(absolutePath, change.newContent, 'utf-8');
|
||||
}
|
||||
|
||||
this.removeChange(changeId);
|
||||
return true;
|
||||
|
||||
@ -180,6 +180,13 @@ async function executeFileDelete(args: FileDeleteArgs): Promise<string> {
|
||||
throw new Error(`不能删除目录,请指定文件路径: ${filePath}`);
|
||||
}
|
||||
|
||||
// 读取文件内容用于变更追踪
|
||||
const oldContent = fs.readFileSync(absolutePath, 'utf-8');
|
||||
|
||||
// 记录删除变更
|
||||
const relativePath = path.relative(workspacePath, absolutePath);
|
||||
changeTracker.trackChange(relativePath, oldContent, '');
|
||||
|
||||
// 删除文件
|
||||
fs.unlinkSync(absolutePath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user