Atom blanks file when using global search and replace


#1

I can repeat this on my own project.

I was doing a global search and replace, replacing:

(for\(SysInt.*=.*0;.*<) ([a-zA-Z_.\[\]\-\>]*size\(\))

With:

$1 (SysInt)$2

on a C++ project with around 400 files.

Whenever I run this ‘Replace All’, around 3 files (the exact files differ each time) are completed blanked of all source code. I do not believe this can be due to a badly formed regex, as (I believe) regexes only match single lines at a time, and many lines will not match that regex at all.

I don’t really know a good way of trying to more carefully pin down what is going wrong… is there some kind of logging I can enable to see what atom is doing?


#2

My assumption was the opposite, so I wrote a simple test:

It appears that in v0.106.0, you are correct. I tested with both regular Find and Replace and Find and Replace in Project.


#3

I have now got a repeatable test case, on an (unfortunately) fairly large and non-public code base.

When I do a global search and replace with the above regexps, 4 files (the same files each time) are blanked (the files become 0 bytes).

If I make a new project with just those 4 files, and run the same global search and replace, the 4 files are not blanked, but instead the correct changes are made.


#4

So it would appear that the bug is not due to the four files, but perhaps one or more other files in the same directory?

@kevinsawicki, @benogle … can either of you speak to whether the order that files are searched in is deterministic?


#5

I now seem table to reproduce this in an open source project I work on as well. This test case could probably be shrunk, but to start I’d be interested to see if it is reproducible on other machines!

I am using Atom 0.106.0

  1. Grab the file: https://www.dropbox.com/s/ed58ysia84bkvig/minion-corrupt.tar.xz and extract it.

  2. Go into the directory and type: find . -type f | xargs wc -c | grep ' 0 '. Notice there are no empty files.

  3. Open the directory with the command ‘atom minion-corrupt’.

  4. Press apple+shift+F to open the “Find in project” dialogue.

  5. Select the ‘.*’ icon (regex)

  6. Put the regex (for\(SysInt.*=.*0;.*<) ([a-zA-Z_.\[\]\-\>]*size\(\)) as the ‘Find in project’

  7. Put $1 (SysInt) $2 as the ‘Replace in project’

  8. Press replace all.

While it seems to finish, there is now an ‘atom helper’ process running constantly.

Also, if you go back into the directory, I find:

$ find . -type f | xargs wc -c | grep ' 0 '
       0 ./minion/constraints/gcc_common.h
       0 ./minion/inputfile_parse/MinionInputReader.hpp
       0 ./minion/inputfile_parse/MinionJSONInputReader.hpp
       0 ./minion/inputfile_parse/MinionThreeInputReader.hpp
       0 ./minion/MILtools/sym_output.h```



#6

Yes, I got the same empty file results that you did.

Can you file a bug on the Find and Replace package?


#7

Done here: https://github.com/atom/find-and-replace/issues/242 . Hopefully this will get looked at.