Hi, I've found a document modified status issue when using "Replace all" with either project or folder Find in... dialogs
When the Replace All button is clicked all the matches are applied to the documents containing them, but the status of the affected documents (which where not modified before issuing the command) does not change to "modified" as it could be expected.
When you close the Find in... dialog it shows a dialog box with the option to save the affected documents. The text in the dialog states that the changes will be lost if you don't save them, which is actually incorrect, or at least misleading, because if you select not to save the documents they still include the applied changes. Their "modified" status though doesn't reflect this.
To reproduce the bug just open two or more files that contain a common string, open a Find in... dialog and do a replace all of that string, check the documents' statuses.
Unless I'm missing something obvious I believe that the additional "save documents" dialog is a lot of work just to save the "⌥⌘S" I'd issue anyway in most cases, but not always. Also, given that the Find in... dialogs aren't modal, so the user can switch back to the documents and continue working, when he gets back to the Find dialog and closes it he may not always remember the context in which he executed the replace operation. When that happens my " keep the control" attitude always forces me to select not to save them ;-) If a builtin "save changes" option is nevertheless required then I believe that an additional "Replace All & Save" button could be more effective. To minimize real estate usage this button could be placed immediately to the right of the Replace All button with just "& Save" as the label. Alternatively, given that in this case the "Replace & Find" action button is apparently always disabled it could simply replace it.
Thanks Gualo
I agree with this; I'd put the problem another way, namely by describing how I use Replace All and what happens when I do.
I do a Find All across multiple documents to see what's going to happen. I decide it's okay. I do a Replace All.
Then I switch to my project and do a Save All just like I've always done.
Now I come back to the dialog and try to start another find. And it says: Do you want to save the documents you just changed? Wait, I just did that!
So there are two problems:
(1) The Find dialog doesn't have a correct notion of whether the documents have been saved; and
(2) It's none of the Find dialog's business anyway! Its job is to find and replace. That's all. The project is where we save. I'm going to switch to the project and do the save, just like I always do.
That's pretty much the same as what Eduardo is saying. m.
PS The way BBEdit solves this is: when you do a global find-and-replace across multiple documents, you get a secondary dialog _first_ asking whether you also want to save automatically. Thus the question is settled up front. I always want to save, so I wouldn't mind having to pass thru such a dialog.
On Sep 5, 2014, at 12:55 AM, Eduardo Francos efrancos@efrancos.com wrote:
Hi, I've found a document modified status issue when using "Replace all" with either project or folder Find in... dialogs
When the Replace All button is clicked all the matches are applied to the documents containing them, but the status of the affected documents (which where not modified before issuing the command) does not change to "modified" as it could be expected.
When you close the Find in... dialog it shows a dialog box with the option to save the affected documents. The text in the dialog states that the changes will be lost if you don't save them, which is actually incorrect, or at least misleading, because if you select not to save the documents they still include the applied changes. Their "modified" status though doesn't reflect this.
To reproduce the bug just open two or more files that contain a common string, open a Find in... dialog and do a replace all of that string, check the documents' statuses.
Unless I'm missing something obvious I believe that the additional "save documents" dialog is a lot of work just to save the "⌥⌘S" I'd issue anyway in most cases, but not always. Also, given that the Find in... dialogs aren't modal, so the user can switch back to the documents and continue working, when he gets back to the Find dialog and closes it he may not always remember the context in which he executed the replace operation. When that happens my " keep the control" attitude always forces me to select not to save them ;-) If a builtin "save changes" option is nevertheless required then I believe that an additional "Replace All & Save" button could be more effective. To minimize real estate usage this button could be placed immediately to the right of the Replace All button with just "& Save" as the label. Alternatively, given that in this case the "Replace & Find" action button is apparently always disabled it could simply replace it.
-- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
On 5 Sep 2014, at 9:55, Eduardo Francos wrote:
I've found a document modified status issue when using "Replace all" with either project or folder Find in... dialogs […]
Besides the implementation issues (that I do intend to address and are one of the remaining issues that have kept me from removing the alpha label) there’s the user experience with the “Do you want to save?” sheet (ignoring that dismissing changes doesn’t undo replacements done in open documents).
Would people be OK with Replace All (after a folder search) auto-saving changes (for non-open documents)? So it would never ask about saving and for open documents, it would do the replacement without saving anything, but for documents that have no open tab, it would simply operate on the data on disk.
Ideally after clicking Replace All the button would turn into Undo Replacements, which would give a way to revert the changes made to the non-open files.
On 6 sept. 2014, at 10:08, Allan Odgaard mailinglist@textmate.org wrote:
On 5 Sep 2014, at 9:55, Eduardo Francos wrote:
I've found a document modified status issue when using "Replace all" with either project or folder Find in... dialogs […]
Would people be OK with Replace All (after a folder search) auto-saving changes (for non-open documents)? So it would never ask about saving and for open documents, it would do the replacement without saving anything, but for documents that have no open tab, it would simply operate on the data on disk.
That seems a good solution to me. Maybe it should handle opened but otherwise unmodified documents the same way as closed documents, and automatically save them as well. It should also be possible to add a .tm_properties setting to have all the files saved including those with an active editor window. Some may prefer to work that way.
Ideally after clicking Replace All the button would turn into Undo Replacements, which would give a way to revert the changes made to the non-open files.
An Undo Replacements could require making the Find in... dialog modal, otherwise the user may edit some files before closing the Find dialog, possibly rendering impossible a full and consistent undo operation. Alternatively, when the user modifies any document then the "Undo Replacements" button could be disabled.
On Sep 6, 2014, at 1:08 AM, Allan Odgaard mailinglist@textmate.org wrote:
Would people be OK with Replace All (after a folder search) auto-saving changes (for non-open documents)? So it would never ask about saving and for open documents, it would do the replacement without saving anything, but for documents that have no open tab, it would simply operate on the data on disk.
I'm someone who does a _lot_ of folder-wide find-and-replace (I still think of this as project-wide, sorry) and this sounds great to me!
The need to save manually afterwards is something I've gotten used to but I've always been somewhat mystified by it. Basically I always want to find/replace/save.
(After all, I'm always under version control, and if I'm in any doubt of the wisdom of a particular change in a particular place, even after previewing what's going to happen, I can always open that document and run through it manually and separately. In the case of very complex and scary regular expression global-find-and-replace I have been known to open every single document individually and do the find-and-replace manually over each one, and I don't mind that at all.) m.
PS This is not directly relevant, but the manual Find dialog has a Replace & Find button but lacks a Replace button (i.e. replace but don't find, so I can inspect the change I just made). It desperately needs this. A common pattern is Replace (but don't Find), look at what this did, now do a Next, then repeat, so that you can look at what you're doing as you go. This is so important that I often switch to BBEdit just to do my replacing! And BBEdit has keyboard shortcuts for both of these. Indeed, in my opinion Replace (but don't Find) should be the default; Replace & Find should be a separate option, possibly its alternate when you hold the Option key or similar.
-- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
Sorry to keep switching gears, but TM now does a thing where Command-G takes me into the next document instead of wrapping around in this document. Is there a way I can get it to stop doing that? By the time I get to the command-G I'm inspecting the individual documents. m.
PS This is not directly relevant, but the manual Find dialog has a Replace & Find button but lacks a Replace button (i.e. replace but don't find, so I can inspect the change I just made). It desperately needs this. A common pattern is Replace (but don't Find), look at what this did, now do a Next, then repeat, so that you can look at what you're doing as you go. This is so important that I often switch to BBEdit just to do my replacing! And BBEdit has keyboard shortcuts for both of these. Indeed, in my opinion Replace (but don't Find) should be the default; Replace & Find should be a separate option, possibly its alternate when you hold the Option key or similar.
-- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
On 6 Sep 2014, at 16:21, Matt Neuburg wrote:
Sorry to keep switching gears, but TM now does a thing where Command-G takes me into the next document instead of wrapping around in this document. Is there a way I can get it to stop doing that?
It always did this — you can “break” it by pressing ⌘E (i.e. place selection on the search clipboard, since the selection is a match, so it should go to next match on ⌘G, but it’ll drop the associated next document). It won’t work if you did a regexp search.
I can add a (hidden) setting if it’s a general issue (and people would prefer to never have it continue to next document).
PS This is not directly relevant, but the manual Find dialog has a Replace & Find button but lacks a Replace button […] in my opinion Replace (but don't Find) should be the default; Replace & Find should be a separate option, possibly its alternate when you hold the Option key or similar.
For a non-regexp search I generally use paste (⌘V) for “replace” — though the main reason for lack of a replace button is mainky the width of 6 buttons in the dialog making it rather wide. But I could probably fold the two replace buttons into one, as you suggest.
Was also thinking about folding all three replace actions into an action menu button (like the print dialog’s PDF button), but I think people would dislike having to go through a menu when doing multiple replacements from the UI.
As for key equivalents (for Replace), if it needs to contain G then we only have ⌥⇧G and ⌃⇧⌘G left.