Community
Participate
Working Groups
Build 20020619 The replace action does not start if the editor is not a text or Java editor. The results are 1) NPE or CCE written to the log 2) The replace dialog does not come up - only the editor opens
Fix is to always open the text editor independent from the registry. We can't do better since text search can't make any assumptions about which editor is registered for file type. The only assumption it can do is that a text editor is appropriate since it was a text search. If the default text editor can't be opened than an error message is shown an replace is stopped.
Note that this bug has nothing to do with replace in text editor. It is global replace provided by Search. Coded fix looks like follows: - before we executed replace it checks if all files that will be manipulated are either closed or opened in an editor that is supported by replace (e.g. instanceof ITextEditor). If not replace operation shows a dialog asking the user to close the editor. - when performing a replace the operation always opens the editor in the default text editor. It remembers the previous default editor and restores this setting to not change the setting of Open->With... If the replace operation can't open a default text editor the replace operation gets aborted and a dialog is shown to the user. Since we open the editor before doing the first change the user will not loose any work by this. Risk of fix: local to Search. Affected files are ReplaceAction and ReplaceDialog and SearchMessages.properties. Risk of code changes: middle. Consequences of not fixing: we end up having NPE or CCE when the user starts a replace operation on files that have an external editor or an incompatible internal editor assigned. Candidates are plugin.xml file, HTML files, ....
Created attachment 1529 [details] Patch that fixes the problem
Does this change only affect replace? That is, when browsing through search results in .java files, I'll still get the CU editor?
Yes, it only affects replace. You still get a Java editor when browsing through search results.
Reviewed by Daniel Megert
Reviewed by Adam Kiezun
Created attachment 1543 [details] Final patch
Marked as fixed