atom / tree-view

🌳 Explore and open project files in Atom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

update git status of file overwritten via fs.writeFileSync

pelallemant opened this issue · comments

commented

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

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.

commented

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.

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.