[gnome-builder/wip/vim] vim: make sure we move past the current word when searching forward.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: make sure we move past the current word when searching forward.
- Date: Tue, 30 Sep 2014 23:39:24 +0000 (UTC)
commit 4492b5174c9e6b0ba3550fe02329488c465a36d5
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 30 16:32:08 2014 -0700
vim: make sure we move past the current word when searching forward.
src/editor/gb-editor-vim.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 7b2a67f..82830de 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1218,8 +1218,8 @@ gb_editor_vim_reverse_search (GbEditorVim *vim)
static void
gb_editor_vim_search (GbEditorVim *vim)
{
+ GtkTextBuffer *buffer;
GbSourceView *source_view;
-
GtkTextIter begin;
GtkTextIter end;
@@ -1235,9 +1235,26 @@ gb_editor_vim_search (GbEditorVim *vim)
gchar *text;
/*
- * Set the search text and begin jumping back to the previous match.
+ * Query the search text.
*/
text = gtk_text_iter_get_slice (&begin, &end);
+
+ /*
+ * Move past the current word so that we don't reselect it.
+ */
+ buffer = gtk_text_view_get_buffer (vim->priv->text_view);
+ if (gtk_text_buffer_get_has_selection (buffer))
+ {
+ gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
+ if (gtk_text_iter_compare (&begin, &end) <= 0)
+ gtk_text_buffer_select_range (buffer, &end, &end);
+ else
+ gtk_text_buffer_select_range (buffer, &begin, &begin);
+ }
+
+ /*
+ * Start searching.
+ */
gb_source_view_begin_search (source_view, GTK_DIR_DOWN, text);
g_free (text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]