[gnome-builder/wip/vim] vim: reselect the previous search upon `/` command.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: reselect the previous search upon `/` command.
- Date: Wed, 1 Oct 2014 21:37:47 +0000 (UTC)
commit 504e2aa1a2a5f0e4292d51066cb05f1b8e6db632
Author: Christian Hergert <christian hergert me>
Date: Wed Oct 1 14:37:41 2014 -0700
vim: reselect the previous search upon `/` command.
src/editor/gb-editor-tab.c | 20 ++++++++++++++++----
src/editor/gb-editor-vim.c | 5 ++---
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 0bec0f6..1d04188 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -921,10 +921,22 @@ on_source_view_begin_search (GbSourceView *source_view,
gtk_source_search_context_set_highlight (priv->search_context, TRUE);
gtk_widget_grab_focus (GTK_WIDGET (priv->search_entry));
- if (direction == GTK_DIR_DOWN)
- gb_editor_tab_move_next_match (tab);
- else if (direction == GTK_DIR_UP)
- gb_editor_tab_move_previous_match (tab);
+ if (search_text)
+ {
+ if (direction == GTK_DIR_DOWN)
+ gb_editor_tab_move_next_match (tab);
+ else if (direction == GTK_DIR_UP)
+ gb_editor_tab_move_previous_match (tab);
+ }
+ else
+ {
+ const gchar *text;
+ guint len;
+
+ text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
+ len = g_utf8_strlen (text, -1);
+ gtk_editable_select_region (GTK_EDITABLE (priv->search_entry), 0, len);
+ }
}
void
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 966ede0..414f3c2 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1569,13 +1569,12 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
case GDK_KEY_slash:
/*
* Focus the search entry for the source view and clear the current
- * search. It would be nice to not clear the current search, but
- * the focus/editable selection process is being a bit annoying.
+ * search. NULL indicates that the search text should be refocused.
*/
if (GB_IS_SOURCE_VIEW (vim->priv->text_view))
{
gb_source_view_begin_search (GB_SOURCE_VIEW (vim->priv->text_view),
- GTK_DIR_DOWN, "");
+ GTK_DIR_DOWN, NULL);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]