Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update git status of file overwritten via fs.writeFileSync #1314

Open
pelallemant opened this issue Apr 30, 2019 · 3 comments

Comments

@pelallemant
Copy link

commented Apr 30, 2019

Prerequisites

Description

I wrote a package which replaces the default TextEditor, by a graphical view in angularjs.
To update the file, I have 2 ways of doing it:

  • directly from the package, using fs.writeFileSync to save it
  • by executing a subprocess (spawn/exec) which will overwrite the file we are viewing

The problem is that when the file is updated by these 2 ways, it is not refreshed in the treeview (no git status).

If I use alt-tab or change the current ubuntu workspace and return to my atom window, then the treeview git status of the file is correctly changed.

Steps to Reproduce

  1. have a custom package
  2. In which the file URI is overwriten either by var fs = require('fs'); fs.writeFileSync(uri, data);, either by a subprocess called with spawn/exec functions.

Expected behavior:

I expect the file git status to be updated

Actual behavior:

The git status of the file isn't updated

Reproduces how often:

100%

Versions

Ubuntu 16.04

atom --version

Atom : 1.35.1
Electron: 2.0.18
Chrome : 61.0.3163.100
Node : 8.9.3

apm --version

apm 2.1.3
npm 6.2.0
node 8.9.3 x64
atom 1.35.1
python 2.7.12
git 2.7.4

Additional Information

@rsese

This comment has been minimized.

Copy link
Member

commented May 11, 2019

Thanks for the report @pelallemant - I chatted with another maintainer and found that this behavior is a known issue on Linux (can you confirm if you see the same behavior on macOS or Windows?) but this work to switch over to a new file watching system may help: atom/atom#19244.

@pelallemant

This comment has been minimized.

Copy link
Author

commented May 11, 2019

Thanks for the answer. I was already told to do that on atom's slack, and had already tried it.
It never worked by switching this mode.

I tried it again right now to ensure it doesn't work.

Each time I :

  • use ctrl + alt + F5 to reload atom's window
  • click on a button in my plugin, which edits the file
  • look if the file in the treeview is updated: it is never shown as updated, until I use alt-tab two times
  • go in the atom settings and change "File System Watcher" to the next value
  • repeat again until no "File System Watcher" available

I tried with:

  • Native Operating System API
  • Experimental filesystem watching library
  • Polling
  • Emulated with atom events

None of them worked. With any of them, if I use alt-tab to focus another window, and alt-tab to refocus the atom's window, then the file appears as modified in the treeview.

My project is currently compatible only for Linux, I cannot test it right now on Windows nor macOS. I could try to make it work in windows soon.

@rsese

This comment has been minimized.

Copy link
Member

commented May 14, 2019

but this work to switch over to a new file watching system may help: atom/atom#19244.

...

I was already told to do that on atom's slack, and had already tried it.
It never worked by switching this mode.

Just to clarify, from your issue report you mentioned you're on 1.35.1 - were you trying the different file system watcher settings from 1.35.1? If so, that won't include the work in atom/atom#19244, that's only available if you've built from source or use the nightly release for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.