import { Uri , WorkspaceEdit , workspace } from 'vscode' ; function toUri ( path ) { if ( typeof path === 'string' ) { return Uri . file ( path ) ; } return path ; } export async function rename ( oldPath , newPath ) { const edit = new WorkspaceEdit ( ) ; edit . renameFile ( toUri ( oldPath ) , toUri ( newPath ) , { ignoreIfExists : true , overwrite : true , } ) ; return workspace . applyEdit ( edit ) ; }