jeromejj / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

Cursor at incorrect location after doing substitution %s/x/y/c when file contains folds #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Bug summary:

Cursor is at the wrong location and below the end of the file after doing
substitutions with confirm flag:   %s/x/y/c

What steps will reproduce the problem?

1. Create this sample text file with 2 folds and start Vim as follows:

$ cat bug.txt
// vim:fdm=marker

// {{{1
x
x
x
// {{{1
x
x
x
$ vim -u NONE -N bug.txt

2. Vim should open file and show 2 folds. enter Ex command:

:%s/x/y/c

and press y multiple times (6 times) to confirm each
substitution one by one. 

What is the expected output? What do you see instead?

At the end of the 6 substitutions, observe that cursor
is at an incorrect location since it is located below
the end of the file (where Vim shows ~)

I would expect cursor to be located on the last line
of the file.

What version of the product are you using? On what operating system?

I'm using Vim-7.3.762 (in terminal or gvim gtk2) on Linux x86_64.

Please provide any additional information below.

Screenshot below shows the cursor at the wrong location,
below the end of file, after pressing  y  6 times to
confirm each substitution.

http://dominique.pelle.free.fr/pic/vim-cursor-bug-after-subst.png

Original issue reported on code.google.com by dominiqu...@gmail.com on 11 Jan 2013 at 9:59

GoogleCodeExporter commented 9 years ago
Christian Brabandt wrote:

> Here is a patch:
> diff --git a/src/ex_cmds.c b/src/ex_cmds.c
> --- a/src/ex_cmds.c
> +++ b/src/ex_cmds.c
> @@ -5200,6 +5200,7 @@
>             EMSG2(_(e_patnotf2), get_search_pat());
>      }
>
> +    changed_window_setting();
>      vim_free(regmatch.regprog);
>  }
>
>
> regards,
> Christian

Thanks Christian. 

I confirm that your patch works.

To avoid useless redraws in most cases, I suppose that we can
update the window if and only if the substitution confirmation
flag was set (:%s/.../.../c) and there are folds.

So how about this?

diff -r b89e2bdcc6e5 src/ex_cmds.c
--- a/src/ex_cmds.c Sun Dec 16 12:50:40 2012 +0100
+++ b/src/ex_cmds.c Sat Jan 12 10:25:48 2013 +0100
@@ -5200,6 +5200,10 @@
        EMSG2(_(e_patnotf2), get_search_pat());
     }

+#ifdef FEAT_FOLDING
+    if (do_ask && hasAnyFolding(curwin))
+   changed_window_setting();
+#endif
     vim_free(regmatch.regprog);
 }

Regards
Dominique

Original comment by dominiqu...@gmail.com on 12 Jan 2013 at 9:34

GoogleCodeExporter commented 9 years ago
Submitted as patch 7.3.772

Original comment by brammool...@gmail.com on 17 Jan 2013 at 6:59