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

Watcher reporting (in)correct file names when saving in IntelliJ & co. #484

Open
vlascik opened this issue Jun 21, 2021 · 1 comment
Open

Comments

@vlascik
Copy link

vlascik commented Jun 21, 2021

So, IntelliJ / WebStorm / PHPStorm family of IDEs have an option in Settings -> Appearance & Behavior -> System Settings -> Back up files before saving. What it does is to save the edited file as <filename.ext>~, filename with a tilde appended to the end before saving to the original.

Sound innocuous enough, but this creates a problem with broccoli / ember-cli on rebuilds - broccoli watcher notices this change first, reports the changed file as e.g. broccoli:watcherAdapter change P:\Project\app/components\test1\template.hbs~ to the system, and "swallows" the consecutive change to the original file.

This is an issue for ember-cli addons that match the file extensions to decide if they should act on the file, e.g. https://github.com/lifeart/ember-ast-hot-load, probably also https://github.com/typed-ember/ember-cli-typescript, maybe also others.

E.g. https://github.com/lifeart/ember-ast-hot-load/blob/e006fad067e7bf818db0b498b4a3fd6ae7f337e6/lib/hot-reloader.js#L6 matches for js/ts/hbs extensions, but gets js~/ts~/hbs~ instead, and fails.

Now, this is definitely an edge case, but given how easy to miss it is and how used IntelliJ IDEs are (#⁠1 or #⁠2 spot along VS Code), maybe it deserves some attention - either as a fix/special case in watcher adapter, or at least a mention of a workaround (disabling the IntelliJ back up setting) in documentation?

@NullVoxPopuli
Copy link

NullVoxPopuli commented Jun 25, 2021

Vim has a similar issue by default. And since this is a problem with all file watching systems in js -- even with webpack, parcel, etc (Last I used them anyway), the solution, for me, was to move the temp files to a different directory.

In my vim config, I have the ability to do this:

set backupdir=~/.local/share/nvim/_backup/    " where to put backup files.
set directory=~/.local/share/nvim/_temp/      " where to put swap files.

So now all my editor specific temp files can't affect any project I'm, regardless of what tools I'm using! 🎉

Maybe the webstorm family of IDEs has a similar option?


Though, a more robust fix would be to find all ecosystem plugins that do file watching and add a $ to their regexes so that the .swp, or in your case, ~ are ignored.

But if your editor has a way to not pollute your project, that'd be a quicker fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants