infrastructure to support remove-selected
fix bug: restart R during debugging doesn't clean debug state