atom/autosave

data loss with new C++ text buffer backend under some cirumstances

Closed this issue ยท 8 comments

Prerequisites

Description

Since Atom 1.19 enabling this plugin can lead to data loss.

Steps to Reproduce

  1. Enable autosave.
  2. Open a file.
  3. Enter test enter.
  4. Save.
  5. Remove new line.
  6. Hit cmd-w.

Expected behavior: [What you expect to happen]

File should either be saved or atom should ask if you want to save the changes to the file.

Actual behavior: [What actually happens]

Empty file is saved.

Reproduces how often: [What percentage of the time does it reproduce?]

Evertime for removing new lines, happens in conjunction with prettier-atom in all cases where prettier changes the file. See: prettier/prettier-atom#264

Versions

  • Atom: 1.19.7
  • Atom-Shell:
  • OS: Mac OS X 10.12.6
  • Misc
    • apm 1.18.4
    • npm 3.10.10
    • node 6.9.5 x64
    • python 2.7.10
    • git 2.11.0

Additional Information

autosave

Disabling the whitespace package prevents this from happening. So I guess this happens whenever a package changes the buffer onWillSave.

Yep, just checked, also happens when using editorconfig instead of whitespace.

@Ben3eeE I'm happy to help reproduce this, I tested this with atom --safe and whitespace and autosave plugins enabled. It always saved an empty file when removing the trailing new line or adding a trailing whitespace to a line.

Wow thanks for the report and I apologize for this very serious regression. I'll be working on this today.

Thanks for working on this, luckily I lost nothing major, just refactoring grunt work ๐Ÿ˜„

~@despairblue I haven't been able to reproduce this yet; at the final step, when I type cmd-w, I am prompted to save the file as expected. If instead of using cmd-w I focus another window, Atom saves the correct contents of the file.~~

Does this happen if you run atom in safe mode?

Oh, nevermind. I had the Ensure Single Trailing Newline option turned off. With that option enabled, I can reproduce this using your steps. Fixing now.

@despairblue This data loss bug is fixed on Atom's master branch. There is still a bug that when autosave is turned on, you get a save prompt when closing a tab with cmd-w. I am looking into that one next.

@maxbrunsfeld Thank you โค๏ธ