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

Command - Undo Replace All #47783

Open
lukaszpolowczyk opened this issue Apr 12, 2018 · 39 comments
Open

Command - Undo Replace All #47783

lukaszpolowczyk opened this issue Apr 12, 2018 · 39 comments
Labels
feature-request Request for new features or functionality search-replace Search and replace issues undo-redo
Milestone

Comments

@lukaszpolowczyk
Copy link

In Search Panel should be button "Undo Replace All", whitch undo all "replaced" changes in all files.
Should to be work like standard undo function, but only for files whitch "Replace All" made a changes.

It looks something simple to introduce. Am I right?

@vscodebot
Copy link

vscodebot bot commented Apr 12, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@lukaszpolowczyk
Copy link
Author

lukaszpolowczyk commented Apr 12, 2018

Bot, as usual, will look for something that has nothing to do with my entry...

@sandy081 sandy081 added feature-request Request for new features or functionality search-replace Search and replace issues labels Apr 16, 2018
@sandy081 sandy081 added this to the Backlog milestone Apr 16, 2018
@spacemansi23
Copy link

Command-undo Replace all

@sandy081
Copy link
Member

Might not be trivial because there could be edits to the file at the location where replace has happened and undo has to ignore that.

@lukaszpolowczyk
Copy link
Author

@sandy081 So the button should work only until some manual change is made to these files.
It would be useful anyway.

@Nowaker
Copy link

Nowaker commented Oct 2, 2018

IntelliJ IDEA family of IDEs has this feature.

@RavenHursT
Copy link

Starting to see the above comment as the reality more and more... :-/

@opensourcegeek
Copy link

It would be really useful to have this feature, I'm git stashing after global replace all at the moment to work around (not ideal).

@ischmal
Copy link

ischmal commented Jun 21, 2019

I support this for instances when I'm not paying attention and accidentally do find-replace to an entire project instead of just the open file. Cleaning up the mess is both humiliating and absurdly tedious.

@gudlakalyan
Copy link

I hope we cann't undo all files , If this possibility there mean its great . please share the same how to undo all replaced files.

Replace all feature is very helpful, but we should be careful when applying this with all files.

Better we should apply some filters like file extension , include and/or exclude files , I attached reference screenshot also.

Visual Code Replace all feature

@CHN-STUDENT
Copy link

I think perhaps we need this command, because if i replace some thing by mistake,i need to replace them by replacing command again.
Or Anyone who have other way?
Thanks.

@moritzWa
Copy link

At least there should be a warning if you accidentally forget to fill out the lower field and replace every occurrence of the searched item with an empty string.

@lukaszpolowczyk
Copy link
Author

@mortizw I mean situations when I have already changed something and LATER I realized that I did it incorrectly or unnecessarily.

A warning is not enough for this.

@Nowaker
Copy link

Nowaker commented Dec 13, 2019

Might not be trivial because there could be edits to the file at the location where replace has happened and undo has to ignore that.

@sandy081 Not really. The "replace all" action should be no different from a manual change that lands on the "undo" stack. Undo is a stack and you can only undo the most recent change. "Replace all" action should land on this very stack, and be undoable when it's on the top of the stack. In this case, there's "no [other] edits to ignore". That's how it works in IntelliJ IDEA.

Worth noting, hitting ^Z in IntelliJ IDEA will trigger an alert like "Do you want to undo replace all?" if "undo all" is on top of the undo stack. This is because a typical ^Z action is usually very small, except when it's undoing a "replace all", and doing so could potentially be disastrous. (But not really since you can CTRL+SHIFT+Z to undo the undo...)

@raikel
Copy link

raikel commented May 20, 2020

I support this for instances when I'm not paying attention and accidentally do find-replace to an entire project instead of just the open file. Cleaning up the mess is both humiliating and absurdly tedious.

Well, I just accidentally modified 423 lines of code in 123 files.

@mpfaff
Copy link

mpfaff commented Jun 2, 2020

And I just screwed up my regex, and now have to fix 132 changes manually.

@RavenHursT
Copy link

This is why I just use JetBrains IDEs for development now... #youGetWhatYouPayFor

@mpfaff
Copy link

mpfaff commented Jun 2, 2020

@RavenHursT I mean, you're right, but there's no way I'm going to pay JetBrains' prices. I'd love to donate a bit to VSCode, but not nearly what JetBrains charge (at least not as a lump sum).

Besides, JetBrains IDEs have many other issues that bother me much more:

  • resource hungry
  • slow
  • take up a large amount of disk space
  • dialogs that butcher tiling WMs
  • themes that don't work on the whole window

@hamikm
Copy link

hamikm commented Jul 6, 2020

Chiming in — this would be a great (albeit nontrivial) feature

@vywern
Copy link

vywern commented Sep 6, 2020

Thanking myself for googling this up right before a major replace all...

@emmanuelnk
Copy link

emmanuelnk commented Nov 6, 2020

Chiming in too.

Of course I could be wrong but I don't see why this is a non-trivial feature to implement. If I do a replace all and I go to an individual file, I can CTRL+Z and undo the replace action in that individual file, and thus I can do this in every file that has had the replace action. So it would be as simple as undoing the last replace call in every file that had that replace action.

Definitely a much needed feature considering how powerful vscode's replace all feature is.

@MohamedLamineAllal
Copy link

MohamedLamineAllal commented Mar 26, 2021

A solution would be to just use the normal undo stack! And to keep a mapping to what a replace all had as entries!

When the replace all undo is triggered! The mapping is used! We check for the whole list of files that were modified! And See if they were top in stack! If all are! And in the right stacked order for all file! Then it's doable and it can be handled!

Now for performance! One can optimize by listening to redo/undo stack of each concerned file!
If no change happened then cool! If some changes happened! Till they got canceled! (we are tracking the hassling block ! That give us the performance point! you don't go and check all! you track it on the go)
One can have even a walk thorugh file by file guiding to undo! (with undo, redo) (so it give the possiblity for copying ! undo! And then when all resolved! the button for undo replace all become enabled! (kind of like a conflict resolution in git walk through)! Simply guided and accessible!

More thinking can go in the thing!

Otherwise too a simple format! Straight forward! Not the most cool thing! But very helpful! Simply make it happen when no changes were made! Because a lot of times one hit replace all! And at the instant it's done! You know you made a mistake! You just want to cancel that! May be that's the most common scenario! (for this only! The implementation is straight forward! After a replace all! All the changed files listing (paths, id whatever) are saved in memory! to revert just do an undo file by file! If any of the file is modified before that! One can keep offering reverting the rest! And open the files with undo problem! And changed!
One can do the hashes too!

EVen though using the stack and with walk through resolution is the cool thing! And require some work! For a cool handling! And simple walk through! In the worst cases!

Now clearly it's a matter of hands! (Time and will) ! Because that can go too as an extension! Why i will not be the one to do it !? My partner is already shouting! Focus

mm i think i may go for an extension! Start with the simple version! Then one see!

@hediet
Copy link
Member

hediet commented Oct 20, 2021

Undo/Redo works with replace all across files:

recording

Is this the requested feature or am I missing something?

@hediet hediet added the info-needed Issue requires more information from poster label Oct 20, 2021
@lukaszpolowczyk
Copy link
Author

lukaszpolowczyk commented Oct 20, 2021

@hediet

Is this the requested feature or am I missing something?

Missing.
It should undo in ALL files, not just open ones.
Replace All works for all files - including unopened ones.
So Undo Replace All should also undo both open and unopened files.

And a button in the Search panel would be useful.
Because what you have given works only via command.

@hediet
Copy link
Member

hediet commented Oct 20, 2021

It should undo in ALL files, not just open ones.

It does so. Closed files are opened automatically:

recording

@lukaszpolowczyk
Copy link
Author

lukaszpolowczyk commented Oct 20, 2021

@hediet
I checked.

There must be at least one file open where Replace All made a change.
And it must be the active tab.

That means:

  • If there is no file open - then Undo will not work.
  • If only files in which Replace All has not made any changes are open - Undo will not work.

Strange behavior.
It's rather to be improved.

The button in the Search Panel would have to work like this:

  • automatically opens at least one file that was recently changed with Replace All
  • executes the Undo command

Then there would be the behavior that is needed.


BTW From which version did VSCode start working as you show? It has always been?

@hediet hediet removed the info-needed Issue requires more information from poster label Oct 20, 2021
@RavenHursT
Copy link

@lukaszpolowczyk so wait.. any file that VSCode wasn't to do a replace all/undo on has to be first opened in the editor before the text changes can be made?

Why isn't something like this just done in memory and just written to disk?

Is there some kind of limitation "under the hood" on replace/undo that only works in files opened in editor tabs?

@lukaszpolowczyk
Copy link
Author

@RavenHursT Replace All worked for both open and unopened files.
Undo worked like "Undo Replace All" only when there is at least one of the files that was changed by Replace All open and active.

I think the context for Undo, is the active tab.

As I wrote, this is strange behavior and should be fixed.

@RavenHursT
Copy link

💯 % agree @lukaszpolowczyk

@brunoaugusto
Copy link

This may be an indirect question to this matter but, how do I keep the files I've performed a replacement on open after the procedure? Because, currently (to me), I Ctrl+SHIFT+H for the action but the files only remain open if I replace each occurrence manually, one entry after another (thus defeating the purpose of a batch replacement). While batching, all files are closed after VSCode finished work with each one of them.

I don't know how to explain but, it's like the replacement action takes place in the background or then it's like if it happens so fast that not all files in which a replacement had been performed end up being registered in the Recently Opened Files.

Here's a hypothetical scenario to describe what just happened to me: I had like 4 files (a, b, c, d) with 3 others previously closed (e, f, g) in history. Then I needed to replace something in 5 other files (h, i, j, k, l). Action completed, affected files closed instead of remaining open as desired, but when I Ctrl+SHIFT+T to reopen them, the files brought to me were, let's say, l, k and g, instead of all five affected and only THEN the other three that were closed before the batch replacing.

Hope I didn't complicate too much with the example >.<

@HamzaAbubakar
Copy link

It should undo in ALL files, not just open ones.

It does so. Closed files are opened automatically:

recording

This saved me from manual undo, thanks dude :)

@lukaszpolowczyk
Copy link
Author

It does so. Closed files are opened automatically:

Read this comment: #47783 (comment)

@CodeBradley
Copy link

It's been 4 years, this still isn't a thing yet?

@sandy081 sandy081 assigned roblourens and unassigned roblourens and sandy081 Mar 8, 2022
@Olshansk
Copy link

@CodeBradley 4 more years!

@cityji
Copy link

cityji commented May 23, 2023

O god,
I made 1911 changes across 94 files and it was a common word, i don't have that much time to find each one and replace it manually :(
I will present it as a feature not a bug or mistake! 🥇

IT WOULD BE REALLY NICE IF THERE IS A BUTTON THAT SAYS "UNDO ALL CHANGES" i would have died with peace 💯

@parthasarathi95
Copy link

I still get the empty array in Android while fetching products using getProducts(). NEED HELP, it's over 24 hrs I have created subscription products in play store, but still not showing

@moonjoungyoung
Copy link

Any update?
Please T.T

@LeonardoRick
Copy link

I agree, this would be a really nice feature!

@RavenHursT
Copy link

Lol.. going on 6 years later..

VSCode is a text editor w/ a whole slew of plugins to make it "act like" a true IDE. Still working in JetBrains and lovin' it.

Just did a "coding exercise" on codingsandbox.io, which uses VSCode as it's basis for it's interface, and good Lawd that was painful! I had to keep refreshing the window just to get TypeScript annotation corrections to be picked up by the editor. Absolute garbage..

JetBrains is like, $10/mo to use ALL of their IDEs.. Again, #YouGetWhatYouPayFor 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality search-replace Search and replace issues undo-redo
Projects
None yet
Development

No branches or pull requests