Fix code copying bug when deleting tabs