After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707177 - API break for the search and replace
API break for the search and replace
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
3.9.x
Other All
: Normal critical
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-31 14:04 UTC by Sébastien Wilmet
Modified: 2013-08-31 19:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
API break: add a GError parameter to replace() and replace_all() (13.07 KB, patch)
2013-08-31 14:04 UTC, Sébastien Wilmet
accepted-commit_now Details | Review
API break: remove the SearchContext:regex-state property (8.38 KB, patch)
2013-08-31 14:51 UTC, Sébastien Wilmet
accepted-commit_now Details | Review

Description Sébastien Wilmet 2013-08-31 14:04:08 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
Comment 1 Sébastien Wilmet 2013-08-31 14:04:58 UTC
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.
Comment 2 Sébastien Wilmet 2013-08-31 14:51:33 UTC
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.
Comment 3 Ignacio Casal Quinteiro (nacho) 2013-08-31 19:18:22 UTC
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.
Comment 4 Ignacio Casal Quinteiro (nacho) 2013-08-31 19:18:58 UTC
Review of attachment 253687 [details] [review]:

Go ahead.
Comment 5 Sébastien Wilmet 2013-08-31 19:47:24 UTC
Commits pushed.