Simplified captureSelectionState() and restoreSelectionState()