atom / autosave

Autosaves buffers when they lose focus
MIT License
64 stars 34 forks source link

whitespace and autosave don't work well together when editing at the end of file #93

Closed andreycizov closed 5 years ago

andreycizov commented 5 years ago

Prerequisites

Description

When using autosave and whitespace plugin with "Ensure Single Trailing Whitespace", one's ability to edit the file at it's end is reduced, since autosave saves the file every 500ms, and whitespace automatically removes the whitespace at the end.

I love to create a few new lines to start a new paragraph before thinking of what exactly should I be writing right now, and then autosave kicks in and saves the file. Whitespace plugin, triggered by autosave, will remove all of the newly created whitespace (although it is useful in this case). It is unreasonably annoying - requires me to always add a non-empty line, so that this behaviour wouldn't distract me.

I can also see how this functionality may require more work than the amount of work it takes to fix it in the first place. So in such scenario it may be nice to hear the opinions of the official maintainers of the plugin.

Also not exactly sure if that's a whitespace or an autosave issue.

Steps to Reproduce

  1. Set up whitespace plugin with "Ensure Single Trailing Whitespace"
  2. Set up autosave plugin (no additional settings needed).
  3. Create a new file and save it somewhere on the disk (so that autosave would start working).
  4. Press enter a few times
  5. Wait a few moments.
  6. Autosave will save the file and whitespace plugin will remove the trailing spaces you had just created, moving the caret to the beginning of the file.

Expected behavior: I expect the whitespace to be automatically removed when I am not directly editing the file (e.g. when autosave runs after I had removed the caret from the end of file).

Actual behavior: Whitespace plugin runs immediately and removes the useful newlines.

Reproduces how often:

100%.

Versions

Atom    : 1.31.2
Electron: 2.0.7
Chrome  : 61.0.3163.100
Node    : 8.9.3
rsese commented 5 years ago

Thanks for the report -

since autosave saves the file every 500ms

Hmmm not sure if I'm missing something but does autosave do that? From the README:

Autosaves editor when they lose focus, are destroyed, or when the window is closed.

I haven't had it enabled in a while so I enabled it and works as described above, it doesn't autosave if I leave the file sitting there but will if I switch tabs, switch to a different application, etc.

Also:

Atom : 1.31.2

I don't believe there were any specific bugs related to autosave since 1.31.2 but the latest release version is 1.34.0 if you want to update and see if that makes a difference.

Lastly, you saw the exact same behavior when you ran in safe mode?

andreycizov commented 5 years ago

I am sorry @rsese - I have mixed up the autosave plugin with autosave-onchange.

My bad, the issue should be closed and I will contact the autosave-onchange plugin author instead.