GNOME Bugzilla – Bug 707177
API break for the search and replace
Last modified: 2013-08-31 19:47:24 UTC
When fixing bugs in gedit, I realized that the API for reporting regex replace errors is not logical. So if you use the gtk_source_search_context_replace() or replace_all() functions, you are concerned. See the attached patch. I've adapted gedit to use the new API, and it works well now: https://git.gnome.org/browse/gedit/log/?h=wip/search-use-new-api
Created attachment 253684 [details] [review] API break: add a GError parameter to replace() and replace_all() gtk_source_search_context_replace() and gtk_source_search_context_replace_all() now have a GError parameter. And GTK_SOURCE_REGEX_SEARCH_REPLACE_ERROR has been removed from the GtkSourceRegexSearchState enum. The reason: the replacement text is given as a parameter to replace() and replace_all(), instead of being in the SearchSettings. Thus, the replacement text is not a part of the "search state". On the other hand, the regex-error and regex-state properties are part of the search state. The regex-error property is not a good place for a replace error. It doesn't make sense to keep a replace error while the replace() or replace_all() is finished since a long time. And there was a bug with the previous API: once a replace error was encountered, it was not possible to search again in the buffer. Except when the search text (or another setting) change. It would have been possible to work around this issue, by clearing the regex-error property if it contains a replace error. And for reporting the replace error to the user, one has to copy the regex-error as soon as it is reported, since it can be cleared later, by another (unrelated) operation. But I think we don't want to keep an error in the API, and have to work around it until the next major release of GtkSourceView. Note that the GtkSourceRegexSearchState enum is still available, to distinguish between a compilation and a matching error.
Created attachment 253687 [details] [review] API break: remove the SearchContext:regex-state property It was used to distinguish between a search error and a replace error. But now the regex replace errors are reported to the GError parameters of replace() and replace_all(). And it is not really useful right now to distinguish between a compilation error and a matching error.
Review of attachment 253684 [details] [review]: Go ahead. Maybe as a really picky thing I'd change tmp_error to something else but go ahead as it is.
Review of attachment 253687 [details] [review]: Go ahead.
Commits pushed.