[gtksourceview] Stop matching bracket search when going out of context class
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview] Stop matching bracket search when going out of context class
- Date: Sun, 3 Jan 2010 12:44:09 +0000 (UTC)
commit c6f24e396e863a3aa14988ca5395e7c0788fd0ec
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sun Jan 3 13:43:55 2010 +0100
Stop matching bracket search when going out of context class
This stops the matching bracket search if the set of context
classes that apply to the matching end iter is _smaller_ then the
set of classes that apply to the start matching iter.
In effect this means that you stop search if you go outside of the
scope (in terms of context classes) that apply to the starting
bracket, and thus will only match brackets in the same string
or comment (this does not affect outside-of string/comment
brackets).
Note: This works well with the current classes and how they are
defined but might need some refinement if we are adding
more classes.
gtksourceview/gtksourcebuffer.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 02e1e80..82c03a8 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -931,12 +931,24 @@ gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
char_cont = 0;
do {
+ gint current_mask;
+
gtk_text_iter_forward_chars (&iter, addition);
cur_char = gtk_text_iter_get_char (&iter);
++char_cont;
+ current_mask = get_context_class_mask (buffer, &iter);
+
+ /* Check if we lost a class, which means we don't look any
+ further */
+ if (current_mask < cclass_mask)
+ {
+ found = FALSE;
+ break;
+ }
+
if ((cur_char == search_char || cur_char == base_char) &&
- cclass_mask == get_context_class_mask (buffer, &iter))
+ cclass_mask == current_mask)
{
if ((cur_char == search_char) && counter == 0) {
found = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]