Open hachpai opened 9 years ago
Super sorry about losing work :(. Are you using git?
Yeah, but one day of work in trash. The really surprising thing is that atom saves directly all the modified files. I try to separate new things unaltered from all the others and git back the distant copy. Imagine, i've changed all 'user' occurences by 'role' without case-sensitivity, in a authorization/authentication project...Nightmare! :-)
Yeah this is crazy. I just experienced:
Replaced " with ' 41197 times in 961 files
Why does Atom replace in files which aren't open? Why did it replace in multiple files in the first place? I see only a "replace all" button, I'm unsure if the changes were saved across all affected files already (appears so, no blue icons on tabs of open files indicating unsaved changes).
Ouch :(
Why did it replace in multiple files in the first place?
There are two kinds of find and replace UIs: find in buffer, and find in project. Sound like find in buffer was what you wanted, but you used find in project.
+1, I've run into this several times (including now) and it's a huge pain to fix the mistake.
twice this week... the last one was 1350 changes in 58 files. Woohoo.
On 03/03/15 15:33, dk253 wrote:
twice this week... the last one was 1350 changes in 58 files. Woohoo.
Heck. I feel your pain.
i just had this happen too... also where is there only a replace all when you find in project? I just want to find all instances of something. I could have sworn there used to be just a find button.
Wow. Danger :mouse: :-) Just got bitten by this as well.
Perhaps a confirm when replacing in unopened files would be appropriate until we can get undo?
:+1: it would be really really useful
+1
I just did this on my entire ~/.atom
directory when trying to replace something in package file. If I'd accidentally opened my home directory instead (which is quite possible for a newb to do by accident), I likely would have lost data.
IMO, this feature should be removed entirely until some safeguards can be put in place, such as:
/
, /home/*/
, or /User/*/
Because this feature is dangerous (or at the very least a major PITA) when used incorrectly, please consider changing the enchancement label.
@benogle
Maybe the most straightforward temporary way could be to remove the find-in-project keybinding from defaults (as it seems problems arise when we accidentally fire it up instead of find-in-file)... I think that completely removing the ability to mass replace would completely prevent atom from spreading now that we are next to 1.0...
Good idea. Although it still doesn't behave how you would expect when you open your home directory, then browse to your project. It's not find-in-project
, it's find-and-replace-everything-atom-currently-has-access-to
. I really think it should display a warning when you try to replace in a directory that is not version controlled. Just something along the lines of:
Make replacement in every file in `/User/john/`?
By the way, I just realized that I ended up making this mistake because Vim-mode rebinds ctrlf to page-down, so I tried ctrlshiftf instead.
@jb Yes, its because it considers the folder you start from to be your project, not the last one you enter...
@andya9: I realized that when I ran find-in-project and it messed up my ~/.atom/
directory...
+1. Just accidentally replaced 'Content-Type' with empty string in the whole project. No way back, I have to revert to last commit.
Suffered from the same issue just now... :sob:
Just occurred to me by mistake. Why is there no confirmation dialog for replace all?
Ouch. +1 for confirmation dialog.
bummer.. same thing happened to me.
When I opened this issue 6 months ago, i didn't expect all those moments of empathy for other coders.
+1
Atom 1.0 shipped without fixing this? :angry:
Would also be good to be able to cancel the operation once started, and to be able to just do a find in project, which was what I was trying to do when Atom replaced the search string with empty space across 38 files
EDIT: Scratch the find in project - that was my stupidity, through muscle memory I hit cmd+enter not enter ... hence did a 'replace all' rather than a find. Confirmation dialog and cancel ability would still be nice.
SECOND EDIT: I really shouldn't file reports when tired. There is an interface design issue with find all in project; it seems there is no 'find all' button shown when you bring this up, just 'replace all'. Hitting 'enter' after putting in your find term executes the find, but having a visible 'find all' button would make the functionality clearer.
as @xpaw said, this is the kinda thing that shouldn't have made it to 1.0!
+1! 1995 changes in 135 files
yow, in atom 1.0 undoing that is broken AND it writes to all the files. That is harsh.
+1! :cry:
At least ask for saving, please!
Yes please. I wanted to replace four spaces with one tab in the opened file but since I typed way too fast I actually replaced two spaces by one tab in 52 files 10895 times. I'm going to cry out loud somewhere now.
+1. I like the Sublime approach to this, which is to open all the files and require them to be saved. Along with the corresponding menu opens to save-all and close-all. Although it could probably be improved upon with a warning system or confirmation dialog.
I just replaced all ' to " Of course Atom crashed, and my heart as well!
A sad short story!
I've let 30 minutes to myself to find how to just add a confirmation box, but time is over and I've to work... I've never found the definition of replace-all command, seems like auto-generated from the command file or I don't know... Maybe I'll give it another chance in few times.
@hachpai Here it is: lib/find-view.coffee#L271-L275. The actual command is registered at line 194 in the same file.
Lost a few hours of work because the find/replace went for the whole file instead of the selection & then I realised there was no undo for it.
It was a fantastic few hours putting that back together.
On a side note; also noticed that general highlighting/selection of text in the editor is rather buggy and the find/replace functions don't always seem to work as expected (such as highlighting a section and then clicking 'in selection' only to have it seemingly deselect your selection)
But anyway. Find/replace needs an undo really badly.
+1 For this. I was trying to replace within a file and miss-replaced on all files. Lost some time too.
Eclipse has a way to preview the changes that is very useful. You can view the "Future diff" and choose which files you want to modify. It could serve as inspiration for a new tool.
" for ' 34406 in 178 files, beat that.... Edit: Didn't see someone had 41k, well I was close
@benogle, could we get some attention to this?
project-find
, until a better solution is found.Am I right in thinking that most people are having this issue because they accidentally used ctrl + F instead of ctrl + f?
Yup I was just moving real fast not paying attention, I would think just having something like if more than 10 files or 100 find and replace actions are going to happen you need to confirm or something to that effect I can't even sudo apt-get update without putting in my password, seems stupid you can find and replace 40,000 things in half a second without a prompt or anything
@zaz, for me it's not really that the command is to easy to hit. It is that there is no catch for the replace action on replace in all files, and it is to easy to trigger the actual replace via keyboard when you are doing a find all.
Yeah, agreed. I was sour earlier but now I'm over it. Atom is still my favorite editor I have ever used hands down. Even if I did it 5 more times I still wouldn't switch. Keep up the good work!
For me, I meant to hit cmd + F, in order to do a find all across the project, but I did a replace all by accident. I entered the find value then tabbed into the replace field to clear it, so the find result wasn't displaying an unrelated replace value. Then I meant to shift+tab back to the find field and press enter to execute. But my right hand was faster than my left and I hit enter when the cursor was still in the replace field.
@r-murphy, definitely done it that way at least once.
as @park9140 said, its not the command that's the issue (for me) its the way that it acts when finding/replacing and the fact there's no undo for it.
Well if any of you has an idea of how Atom works internally, a lot of people would appreciate a fix. I don't know how to do much more than just disable hotkeys.
This is a pretty big issue for me as well - I don't think the command is bad, I think the lack of undo for it is just kind of broken in general. Would there be any internal problems if Atom logged the results of directory-wide actions like this and gave you a way to do some type of global undo?
I can see this being an issue for other commands from plugins as well. (Okay, whitespace cleanup on all of my code; oh I didn't commit my actual changes yet and now everything is mixed together)
Ouch, just got bitten by this.
Could we copy the behaviour from TextMate or something similar? (give you a preview first).
+1, currently discarding changes manually on 292 files :hammer: If anyone knows a better way..
@soukiassianb unfortunately, the best way is reverting through Git—but this is not always an option. :(
Hello,
I've spent 2 hours to undo a bad replace all in project. An not-undoable operation for the moment. It's REALLY dangerous :-1:
Miss this function truly.
thank you
ph