Save the cursor position when changing buffer