Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Find and replace deletes the contents of files #242

Closed
ChrisJefferson opened this issue Jun 25, 2014 · 3 comments · Fixed by atom/atom#2783
Closed

Find and replace deletes the contents of files #242

ChrisJefferson opened this issue Jun 25, 2014 · 3 comments · Fixed by atom/atom#2783
Assignees
Labels

Comments

@ChrisJefferson
Copy link

From http://discuss.atom.io/t/atom-blanks-file-when-using-global-search-and-replace/10406/5, this test cases shows find and replace deleting the contents of files while doing a global search and replace.

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```

@benogle benogle self-assigned this Jun 25, 2014
@benogle benogle added the bug label Jun 25, 2014
@benogle
Copy link
Contributor

benogle commented Jun 25, 2014

Is there anything in the console?

@benogle
Copy link
Contributor

benogle commented Jun 25, 2014

I can repro. This is highlighting several issues:

  • replace quickly exhausts file descriptors
  • temp.cleanup() is cleaning up temp files when they are still in use
  • replace tries to transform every line
  • there needs to be a lot more error handling when reading files

@benogle
Copy link
Contributor

benogle commented Jul 1, 2014

The call to temp.cleanup() was causing this issue. It was cleaning up temp files before they could get written to the original location, so it would write an empty file.

Thanks for the nice test case.

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

Successfully merging a pull request may close this issue.

2 participants