I often have a situation where I copy text from a PDF (generated by others out of my control) to a writer document. This results in multiple sentence fragments forming separate paragraphs instead of a single paragraph (each line in the PDF comes across as a paragraph rather than a carriage return). It is convenient to use Find and Replace with regular expressions to search for the end of each line ($) in the copied text (except the last) in a highlighted series of these small paragraphs and replace it with a space (' ') to rejoin these paragraphs. Should this go wrong and through user error be applied to the whole document due to a failure to select a section of text properly, the entire document becomes a single line of text (expected behaviour). However, it does not seem possible to undo and I have had to revert to saved versions in the past.
I think you might be running out of your undo stack. I tried it by copying your description and using it as a test content. I could undo just fine. I'm in a hurry, so can't research how to raise the limit. I only found this with a web search, but the option isn't there anymore: Tools>Options>LibreOffice>Memory>Number of steps
That is possible - the documents I have experienced this with have been large (50 pages of text or more).
I got advice that it is under Tools - Options - Advanced - Expert config. Then search for Undo and look for org.openoffice.Office.Common. It has a property "Steps". Edit it and raise it accordingly. Be sure to have enough memory..
I got comments from Cloph on IRC: There's a combine-single-line-paragraphs autocorrect feature... should work better than search end-of-line and replace with a space, and will avoid messing up the whole document. and of course you could enable track changes and undo with that as well. I will close this, if you don't mind.
Thanks! I had no idea about that autocorrect option. It is, indeed, a much better solution.