[gnome-builder/wip/vim] vim: make searching a bit more resilient
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: make searching a bit more resilient
- Date: Wed, 1 Oct 2014 21:31:09 +0000 (UTC)
commit 249a33cd5732d6c30776c00211074c2ef583efa9
Author: Christian Hergert <christian hergert me>
Date: Wed Oct 1 14:30:53 2014 -0700
vim: make searching a bit more resilient
In particular, try to fix some pesky auto selection weirdness.
We can't just clear the selection since we want to know the word
the cursor is currently on.
src/editor/gb-editor-vim.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index cd7b9b1..966ede0 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1214,8 +1214,8 @@ gb_editor_vim_clear_selection (GbEditorVim *vim)
static void
gb_editor_vim_reverse_search (GbEditorVim *vim)
{
+ GtkTextBuffer *buffer;
GbSourceView *source_view;
-
GtkTextIter begin;
GtkTextIter end;
@@ -1225,17 +1225,28 @@ gb_editor_vim_reverse_search (GbEditorVim *vim)
return;
source_view = GB_SOURCE_VIEW (vim->priv->text_view);
-
- gb_editor_vim_clear_selection (vim);
+ buffer = gtk_text_view_get_buffer (vim->priv->text_view);
if (gb_editor_vim_select_current_word (vim, &begin, &end))
{
gchar *text;
/*
- * Set the search text and begin jumping back to the previous match.
+ * Fetch the search text.
*/
text = gtk_text_iter_get_slice (&begin, &end);
+
+ /*
+ * Move to right before the current word and clear the selection.
+ */
+ if (gtk_text_iter_compare (&begin, &end) <= 0)
+ gtk_text_buffer_select_range (buffer, &begin, &begin);
+ else
+ gtk_text_buffer_select_range (buffer, &end, &end);
+
+ /*
+ * Start searching.
+ */
gb_source_view_begin_search (source_view, GTK_DIR_UP, text);
g_free (text);
@@ -1271,8 +1282,6 @@ gb_editor_vim_search (GbEditorVim *vim)
source_view = GB_SOURCE_VIEW (vim->priv->text_view);
- gb_editor_vim_clear_selection (vim);
-
if (gb_editor_vim_select_current_word (vim, &begin, &end))
{
gchar *text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]