[gtksourceview/wip/chergert/vim] push a jump on / ? and :s commands
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] push a jump on / ? and :s commands
- Date: Fri, 12 Nov 2021 00:56:46 +0000 (UTC)
commit 885f4d376ee3e27d57353a66a0a687a143d2f3f1
Author: Christian Hergert <chergert redhat com>
Date: Thu Nov 11 16:48:21 2021 -0800
push a jump on / ? and :s commands
gtksourceview/vim/gtk-source-vim-command.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index 2f1f3202..b3e9f30c 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -690,6 +690,7 @@ gtk_source_vim_command_search (GtkSourceVimCommand *self)
if (gtk_source_search_context_forward (context, &iter, &match, NULL, NULL))
{
+ gtk_source_vim_state_push_jump (GTK_SOURCE_VIM_STATE (self), &iter);
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &match, &match);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match, 0.25, TRUE, 1.0, 0.0);
@@ -740,6 +741,7 @@ gtk_source_vim_command_search_reverse (GtkSourceVimCommand *self)
if (gtk_source_search_context_backward (context, &iter, &match, NULL, NULL))
{
+ gtk_source_vim_state_push_jump (GTK_SOURCE_VIM_STATE (self), &iter);
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &match, &match);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match, 0.25, TRUE, 1.0, 0.0);
@@ -760,22 +762,24 @@ gtk_source_vim_command_line_number (GtkSourceVimCommand *self)
if (parse_number (self->options, &line))
{
+ GtkSourceBuffer *buffer;
GtkSourceView *view;
- GtkTextBuffer *buffer;
GtkTextIter iter;
if (line > 0)
line--;
view = gtk_source_vim_state_get_view (GTK_SOURCE_VIM_STATE (self));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_get_iter_at_line (buffer, &iter, line);
+ buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &iter, NULL);
+
+ gtk_source_vim_state_push_jump (GTK_SOURCE_VIM_STATE (self), &iter);
+ gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer), &iter, line);
while (!gtk_text_iter_ends_line (&iter) &&
g_unichar_isspace (gtk_text_iter_get_char (&iter)))
gtk_text_iter_forward_char (&iter);
- gtk_text_buffer_select_range (buffer, &iter, &iter);
+ gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &iter, 0.25, TRUE, 1.0, 0.0);
self->ignore_mark = TRUE;
@@ -916,6 +920,7 @@ gtk_source_vim_command_search_replace (GtkSourceVimCommand *self)
gboolean wrapped = FALSE;
gboolean flag_g = FALSE;
gboolean flag_i = FALSE;
+ gboolean found_match = FALSE;
guint line = 0;
int last_line;
@@ -960,6 +965,16 @@ gtk_source_vim_command_search_replace (GtkSourceVimCommand *self)
{
guint cur_line = gtk_text_iter_get_line (&match_start);
+ if (!found_match)
+ {
+ GtkTextIter cursor;
+
+ gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &cursor, NULL);
+ gtk_source_vim_state_push_jump (GTK_SOURCE_VIM_STATE (self), &cursor);
+
+ found_match = TRUE;
+ }
+
if (self->mark_end)
{
GtkTextIter end;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]