@@ -6,7 +6,6 @@ import { dictionary } from '@shared/constants/dictionary'
66import { Logger } from '@shared/utils/logger'
77import { OriginalFileState } from '@/commands/apply-chat-response-command/types/original-file-state'
88
9- // Helper to replace fs.existsSync with a non-throwing async version
109const uri_exists = async ( uri : vscode . Uri ) : Promise < boolean > => {
1110 try {
1211 await vscode . workspace . fs . stat ( uri )
@@ -256,14 +255,12 @@ const relocate_file = async (params: {
256255 return false
257256 }
258257
259- // Create directory for new path if needed
260258 const new_uri = vscode . Uri . file ( new_safe_path )
261259 const new_dir_uri = vscode . Uri . file ( path . dirname ( new_safe_path ) )
262260 if ( ! ( await uri_exists ( new_dir_uri ) ) ) {
263261 await vscode . workspace . fs . createDirectory ( new_dir_uri )
264262 }
265263
266- // Close any open editors for the old file
267264 const text_editors = vscode . window . visibleTextEditors . filter (
268265 ( editor ) => editor . document . uri . toString ( ) == old_uri . toString ( )
269266 )
@@ -388,18 +385,16 @@ export const undo_files = async (params: {
388385 data : state . file_path
389386 } )
390387 console . error ( `Cannot undo file with unsafe path: ${ state . file_path } ` )
391- continue // Skip this file
388+ continue
392389 }
393390 let file_uri = vscode . Uri . file ( safe_path )
394391
395392 if ( state . file_state == 'new' && ! state . file_path_to_restore ) {
396393 if ( await uri_exists ( file_uri ) ) {
397- // Close any open editors for this file before deleting
398394 const text_editors = vscode . window . visibleTextEditors . filter (
399395 ( editor ) => editor . document . uri . toString ( ) === file_uri . toString ( )
400396 )
401397
402- // Close all tabs for this file across all editor groups
403398 const tabs_to_close : vscode . Tab [ ] = [ ]
404399 for ( const tab_group of vscode . window . tabGroups . all ) {
405400 tabs_to_close . push (
@@ -416,7 +411,6 @@ export const undo_files = async (params: {
416411 await vscode . window . tabGroups . close ( tabs_to_close )
417412 }
418413
419- // Fallback: close active editor if it's still showing this file
420414 for ( const editor of text_editors ) {
421415 await vscode . window . showTextDocument ( editor . document , {
422416 preview : false ,
@@ -467,8 +461,6 @@ export const undo_files = async (params: {
467461 }
468462 if ( ! safe_path ) continue
469463 file_uri = vscode . Uri . file ( safe_path )
470- // For existing files that were modified, restore original content.
471- // This also handles files that were deleted (by recreating them).
472464 if ( ! ( await uri_exists ( file_uri ) ) ) {
473465 try {
474466 const dir_uri = vscode . Uri . file ( path . dirname ( safe_path ) )
0 commit comments