coteditor / CotEditor

Lightweight Plain-Text Editor for macOS
https://coteditor.com
Other
6.49k stars 432 forks source link

[Data loss] When using "Save As…", CotEditor overwrites old file as well #1718

Closed tkrajacic closed 2 months ago

tkrajacic commented 2 months ago

Description

When editing a file on macOS, there is the option of saving yet unsaved work (keeping the saved file in the previous state) into a new file by using "Save As…" (holding "Option" when opening the "File" menu)

CotEditor erroneously save the changes to the new AND old file, thereby deleting your old content in the original file. This is a serious bug which results in data loss.

To Reproduce

  1. Create a textfile
  2. type "1, 2" and save it (file1.txt)
  3. Delete the 2 (so it reads "1")
  4. Use "Save As…" to save the unsaved changes into a new file (file2.txt)

Expected behavior

file1.txt contains "1,2" file2.txt contains "1"

CotEditor version

5.0.0 (674)

macOS version

15.0

Additional context

No response

1024jp commented 2 months ago

By default, CotEditor automatically saves (overwrites) the document while editing. You can change this behavior by toggling the "Enable Auto Save with Versions" option in the General Settings.

Screenshot 2024-09-20 at 14 32 53

If you have the issue even when you disabled the Autosave feature, let me know if the phenomenon appears only after updating to CotEditor 5.0.0, or you haven't tried the previous versions.

tkrajacic commented 2 months ago

You are of course 100% correct, and that was the issue. Turning off auto-save restored correct behavior.

I suppose you can close this issue as it seems to be working as intended, even though I would have expected different behavior. Thank you for looking into this.

1024jp commented 2 months ago

Thank you for the reply. I'm glad you were able to resolve this issue.

CotEditor enables Autosave as default since Apple advocates that modern apps should be. I understand the need not to use Autosave, though, so CotEditor provides the option to disable it.

tkrajacic commented 2 months ago

I wonder if it would be possible though to make sure that once a document duplicated with "Save As…", that the previous document is reset to its last user-saved state. This would be the expected behavior imho.

1024jp commented 2 months ago

It depends on the use case, I suppose. In addition, since the current behavior is provided by the standard framework by Apple, I believe this is the standard behavior and should not be changed. A lot of other native macOS apps work already in the same manner.