Fix swap doc

Fix problem during swap doc with collapsed lines to doc without collapsed lines and empty content.
It throw error ```There is no line 1 in the document.```