Edit doc preserves caret and selection on save