This is a copy of a bug I reported on openSUSE's bugzilla. OS is openSUSE Leap 42.3.
$ rpm -q libreoffice-calc
I have just lost 2 documents because of this bug. First time I had a doubt that maybe I made a mistake. Now I am sure this is a bug and not a user mistake.
How to reproduce:
$ mkdir ~/Documents/bug
$ cd ~/Documents/bug
$ touch data.ods
$ echo foo > crap.csv
Now start Libreoffice Calc, type "bar" in the cell A1 and save the new spreadsheet. Navigate to ~/Documents/bug and select "data.ods" in the list (this is the key step to trigger the bug!) Then edit the input field at the top to replace ".ods" with ".csv". The input field now reads "data.csv". Press Enter and, if asked, confirm that you want to save in CSV format. You are prompted for formatting details of the CSV file, click OK.
Now look at the name of your document in the top bar. It is NOT "data.csv" as you asked. It is "crap.csv". You can check that file "crap.csv" now contains "bar":
$ cat crap.csv
The original contents of the document is forever lost. Libreoffice did not even ask for confirmation before overwriting the existing document.
The bug is not specific to Calc, the same bug can be reproduced with Writer, using appropriate filename extensions.
Further investigation revealed that this bug only happens with the gtk3 UI. When using the gtk, kde or generic UI, the bug does not happen.
The bug was also reproduced with versions 126.96.36.199 and 188.8.131.52 on the same system, downloaded from build.opensuse.org, as well as with version 184.108.40.206 on openSUSE Tumbleweed (32-bit x86).
*** This bug has been marked as a duplicate of bug 119790 ***
Thank you very much Caolán. I looked for duplicates before creating this bug, but unfortunately did not find that one, sorry.