[gnome-builder] Revert "search: Fix issue with searching and restore to position before search"
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] Revert "search: Fix issue with searching and restore to position before search"
- Date: Sun, 17 May 2015 21:24:53 +0000 (UTC)
commit 34dd140086d77f9f91708834faca2e4df4733479
Author: Christian Hergert <christian hergert me>
Date: Sun May 17 14:24:19 2015 -0700
Revert "search: Fix issue with searching and restore to position before search"
This reverts commit 096e30e62d6b0357fd8975e339d3562fb7bc5cd6.
Reverting until we get * and # fixed in vim mode, and move insert cursor upon Return from search entry.
libide/ide-source-view.c | 1 -
src/editor/gb-editor-frame-actions.c | 16 +++-------
src/editor/gb-editor-frame-private.h | 1 -
src/editor/gb-editor-frame.c | 56 ++++++++++++----------------------
4 files changed, 25 insertions(+), 49 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 623e408..7991d84 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -1091,7 +1091,6 @@ ide_source_view__search_settings_notify_search_text (IdeSourceView *se
if (gtk_source_search_context_forward (priv->search_context, &begin_iter,
&match_begin, &match_end))
{
- gtk_text_buffer_select_range (buffer, &match_begin, &match_end);
gtk_text_buffer_move_mark (buffer, priv->rubberband_mark, &match_begin);
ide_source_view_scroll_mark_onscreen (self, priv->rubberband_mark, TRUE, 0.5, 0.5);
}
diff --git a/src/editor/gb-editor-frame-actions.c b/src/editor/gb-editor-frame-actions.c
index cf9c263..e890816 100644
--- a/src/editor/gb-editor-frame-actions.c
+++ b/src/editor/gb-editor-frame-actions.c
@@ -28,17 +28,13 @@ gb_editor_frame_actions_find (GSimpleAction *action,
{
GbEditorFrame *self = user_data;
GtkTextBuffer *buffer;
- GtkTextMark *mark;
- GtkTextIter iter;
+ GtkTextIter start_sel;
+ GtkTextIter end_sel;
g_assert (GB_IS_EDITOR_FRAME (self));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
- /* Get the position of the insert mark */
- mark = gtk_text_buffer_get_insert (buffer);
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
-
/*
* If the buffer currently has a selection, we prime the search entry with the
* selected text. If not, we use our previous search text in the case that it was
@@ -47,9 +43,6 @@ gb_editor_frame_actions_find (GSimpleAction *action,
if (gtk_text_buffer_get_has_selection (buffer))
{
- GtkTextIter start_sel;
- GtkTextIter end_sel;
-
gtk_text_buffer_get_selection_bounds (buffer, &start_sel, &end_sel);
if (gtk_text_iter_get_line (&start_sel) == gtk_text_iter_get_line (&end_sel))
@@ -61,9 +54,10 @@ gb_editor_frame_actions_find (GSimpleAction *action,
}
}
else if (self->previous_search_string != NULL)
- gtk_entry_set_text (GTK_ENTRY (self->search_entry), self->previous_search_string);
+ {
+ gtk_entry_set_text (GTK_ENTRY (self->search_entry), self->previous_search_string);
+ }
- gtk_text_buffer_move_mark (buffer, self->search_mark, &iter);
gtk_revealer_set_reveal_child (self->search_revealer, TRUE);
gtk_widget_grab_focus (GTK_WIDGET (self->search_entry));
}
diff --git a/src/editor/gb-editor-frame-private.h b/src/editor/gb-editor-frame-private.h
index db404df..0d7c633 100644
--- a/src/editor/gb-editor-frame-private.h
+++ b/src/editor/gb-editor-frame-private.h
@@ -46,7 +46,6 @@ struct _GbEditorFrame
GbEditorMapBin *source_map_container;
IdeSourceMap *source_map;
GtkOverlay *source_overlay;
- GtkTextMark *search_mark;
IdeAnimation *map_animation;
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 4a7a29b..874fd34 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -292,7 +292,6 @@ gb_editor_frame_set_document (GbEditorFrame *self,
mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (document));
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (document), &iter, mark);
- self->search_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (document), NULL, &iter, FALSE);
on_cursor_moved (document, &iter, self);
/*
@@ -407,43 +406,35 @@ gb_editor_frame__search_key_press_event (GbEditorFrame *self,
GdkEventKey *event,
GdTaggedEntry *entry)
{
+ GtkTextBuffer *buffer;
+
g_assert (GB_IS_EDITOR_FRAME (self));
g_assert (GD_IS_TAGGED_ENTRY (entry));
switch (event->keyval)
{
case GDK_KEY_Escape:
- {
- GtkTextIter iter;
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
+ /* stash the search string for later */
+ g_free (self->previous_search_string);
+ g_object_get (self->search_entry, "text", &self->previous_search_string, NULL);
- /* stash the search string for later */
- g_free (self->previous_search_string);
- g_object_get (self->search_entry, "text", &self->previous_search_string, NULL);
+ /* clear the highlights in the source view */
+ ide_source_view_clear_search (self->source_view);
- /* clear the highlights in the source view */
- ide_source_view_clear_search (self->source_view);
-
- /* disable rubberbanding and ensure insert mark is on screen */
- ide_source_view_set_rubberband_search (self->source_view, FALSE);
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, self->search_mark);
- ide_source_view_scroll_to_iter (self->source_view, &iter, 0.0, TRUE, 0.5, 0.5, TRUE);
+ /* disable rubberbanding and ensure insert mark is on screen */
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
+ ide_source_view_set_rubberband_search (self->source_view, FALSE);
+ ide_source_view_scroll_mark_onscreen (self->source_view,
+ gtk_text_buffer_get_insert (buffer),
+ TRUE,
+ 0.5,
+ 0.5);
- /* finally we can focus the source view */
- gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
+ /* finally we can focus the source view */
+ gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
- /*
- * Unfortunately We have to place the cursor after grabbing focus
- * because ide-source-view has its own handler when focused which
- * sets the cursor back to the insert mark which at that time points
- * to the last search found
- */
- gtk_text_buffer_place_cursor (buffer, &iter);
+ return GDK_EVENT_STOP;
- return GDK_EVENT_STOP;
- }
case GDK_KEY_KP_Enter:
case GDK_KEY_Return:
if ((event->state & GDK_SHIFT_MASK) == 0)
@@ -720,19 +711,12 @@ gb_editor_frame_dispose (GObject *object)
ide_clear_weak_pointer (&self->map_animation);
- if (self->source_view)
+ if (self->source_view && self->cursor_moved_handler)
{
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
- if (self->cursor_moved_handler)
- ide_clear_signal_handler (buffer, &self->cursor_moved_handler);
-
- if (self->search_mark != NULL)
- {
- gtk_text_buffer_delete_mark (buffer, self->search_mark);
- self->search_mark = NULL;
- }
+ ide_clear_signal_handler (buffer, &self->cursor_moved_handler);
}
g_clear_object (&self->search_entry_tag);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]