[gtksourceview/wip/chergert/vim] s&r tests and fixes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] s&r tests and fixes
- Date: Tue, 9 Nov 2021 03:27:11 +0000 (UTC)
commit 8b1b56f84548c22e31293e0963869c63ae2edcf2
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 8 19:27:06 2021 -0800
s&r tests and fixes
gtksourceview/vim/gtk-source-vim-command.c | 9 +++++++--
gtksourceview/vim/gtk-source-vim-marks.c | 6 +-----
testsuite/test-vim-input.c | 13 +++++++++++++
3 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index d744a7bf..a4ce77ca 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -948,7 +948,7 @@ gtk_source_vim_command_search_replace (GtkSourceVimCommand *self)
{
GtkTextIter end;
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &end, self->mark_end);
- if (gtk_text_iter_compare (&end, &match_end) < 0)
+ if (gtk_text_iter_compare (&match_start, &end) >= 0)
break;
}
else if (gtk_text_iter_get_line (&match_start) != line)
@@ -1367,9 +1367,14 @@ parse_position (GtkSourceVimState *current,
* the marks by default.
*/
if (*c == '<' && !gtk_text_iter_starts_line (iter))
+ {
gtk_text_iter_set_line_offset (iter, 0);
+ }
else if (*c == '>' && !gtk_text_iter_ends_line (iter))
- gtk_text_iter_forward_to_line_end (iter);
+ {
+ if (gtk_text_iter_starts_line (iter))
+ gtk_text_iter_backward_char (iter);
+ }
*str = ++c;
return TRUE;
diff --git a/gtksourceview/vim/gtk-source-vim-marks.c b/gtksourceview/vim/gtk-source-vim-marks.c
index c1540e49..cab4dd77 100644
--- a/gtksourceview/vim/gtk-source-vim-marks.c
+++ b/gtksourceview/vim/gtk-source-vim-marks.c
@@ -87,11 +87,7 @@ gtk_source_vim_marks_get_mark (GtkSourceVimMarks *self,
buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &iter, &selection);
- if (gtk_text_iter_equal (&iter, &selection))
- {
- return gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
- }
- else if (gtk_text_iter_compare (&iter, &selection) < 0)
+ if (gtk_text_iter_compare (&iter, &selection) <= 0)
{
if (name[0] == '<')
return gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
diff --git a/testsuite/test-vim-input.c b/testsuite/test-vim-input.c
index f01791b3..7fcfd203 100644
--- a/testsuite/test-vim-input.c
+++ b/testsuite/test-vim-input.c
@@ -118,6 +118,7 @@ static void
test_delete (void)
{
run_test ("a word here.", "v$x", "");
+ run_test ("t\nt\n", "Vx", "t\n");
run_test ("a word here.", "vex", " here.");
run_test ("line1", "dd", "");
run_test ("line1\n", "dj", "");
@@ -191,6 +192,18 @@ test_search_and_replace (void)
g_free (replace);
g_free (options);
}
+
+ run_test ("test test test test", ":s/test\n", " test test test");
+ run_test ("test test test test", ":s/test/bar\n", "bar test test test");
+ run_test ("test test test test", ":s/test/bar/g\n", "bar bar bar bar");
+ run_test ("test test test test", ":s/TEST/bar/gi\n", "bar bar bar bar");
+ run_test ("test test test test", ":s/TEST/bar\n", "test test test test");
+ run_test ("t t t t\nt t t t\n", ":s/t/f\n", "f t t t\nt t t t\n");
+ run_test ("t t t t\nt t t t\n", ":%s/t/f\n", "f t t t\nf t t t\n");
+ run_test ("t t t t\nt t t t\n", ":%s/t/f/g\n", "f f f f\nf f f f\n");
+ run_test ("t t t t\nt t t t\n", ":.,$s/t/f\n", "f t t t\nf t t t\n");
+ run_test ("t t\nt t\nt t\n", ":.,+1s/t/f\n", "f t\nf t\nt t\n");
+ run_test ("t t t t\nt t t t\n", "V:s/t/f\n", "f t t t\nt t t t\n");
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]