[gnome-builder/gnome-builder-3-18] source-view: wrap around search if we didn't find anything
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-18] source-view: wrap around search if we didn't find anything
- Date: Tue, 13 Oct 2015 07:37:03 +0000 (UTC)
commit b26d80277da7ad425e01d7593aa4c9f9efe18ef0
Author: Christian Hergert <christian hergert me>
Date: Sun Oct 4 17:27:15 2015 -0700
source-view: wrap around search if we didn't find anything
libide/ide-source-view.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 72d80eb..300973f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -3338,6 +3338,7 @@ ide_source_view_real_move_error (IdeSourceView *self,
GtkTextBuffer *buffer;
GtkTextMark *insert;
GtkTextIter iter;
+ gboolean wrap_around = TRUE;
gboolean (*movement) (GtkTextIter *) = NULL;
g_assert (IDE_IS_SOURCE_VIEW (self));
@@ -3345,6 +3346,11 @@ ide_source_view_real_move_error (IdeSourceView *self,
if (!priv->buffer)
return;
+ if (dir == GTK_DIR_RIGHT)
+ dir = GTK_DIR_DOWN;
+ else if (dir == GTK_DIR_LEFT)
+ dir = GTK_DIR_UP;
+
/*
* TODO: This is not particularly very efficient. But I didn't feel like
* plumbing access to the diagnostics set and duplicating most of
@@ -3353,7 +3359,7 @@ ide_source_view_real_move_error (IdeSourceView *self,
* we should change to that.
*/
- if ((dir == GTK_DIR_DOWN) || (dir == GTK_DIR_RIGHT))
+ if (dir == GTK_DIR_DOWN)
movement = gtk_text_iter_forward_line;
else
movement = gtk_text_iter_backward_line;
@@ -3362,6 +3368,7 @@ ide_source_view_real_move_error (IdeSourceView *self,
insert = gtk_text_buffer_get_insert (buffer);
gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+wrapped:
while (movement (&iter))
{
IdeDiagnostic *diag;
@@ -3392,6 +3399,16 @@ ide_source_view_real_move_error (IdeSourceView *self,
break;
}
}
+
+ if (wrap_around)
+ {
+ if (dir == GTK_DIR_DOWN)
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (priv->buffer), &iter);
+ else
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (priv->buffer), &iter);
+ wrap_around = FALSE;
+ goto wrapped;
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]