atom / whitespace

Atom whitespace package
MIT License
94 stars 67 forks source link

Does not ignore whitespace on current line when switching tabs #180

Open Aerijo opened 6 years ago

Aerijo commented 6 years ago

Prerequisites

Description

The Ignore Whitespace on Current Line setting is not respected.

Steps to Reproduce

  1. Ensure autosave on lose focus is enabled
  2. Open two editor tabs
  3. In the first, set the language to JavaScript, paste in the following, and place your cursor where the pipe is (delete the pipe)
    {
    |
    }
  4. Switch to the other tab, and then back to this one

Expected behavior: [What you expect to happen] No change

Actual behavior: [What actually happens] Whitespace eaten

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

I can't reliably reproduce every time, but it will happen when I try enough times.

Versions

Atom    : 1.30.0-beta2
Electron: 2.0.5
Chrome  : 61.0.3163.100
Node    : 8.9.3

whitespace 0.37.6

Additional Information

Seems to be a regression introduced by #169. It uses the getActiveTextEditor API, meaning to grab the file we are leaving, but instead grabs the editor we arrive at. It then sees that the buffer is not the same as the actual editor, and doesn't look for any cursors.

Probably related is that saving is async, so the event is likely firing after we switch tabs (or something to that effect).

Aerijo commented 6 years ago

I can't reproduce on Stable 1.28.2

Aerijo commented 6 years ago

So I looked closer at the test cases in #169, and it's number 3 that is the issue. From it's description, I believe it's meant to be for when saving all files with the command prompt. This makes sense, but unfortunately conflicts with autosave as you change tabs.

I guess the question might be is this expected? I obviously don't like it killing whitespace while I'm writing a function & switch to another tab to look at something. But I don't know if these events can be distinguished, or even if other people actually want this.