Hi list,

I'm writing a Vim plug-in that's sort of like :mksession on steroids. When I realized how difficult it would be to reproduce any given split window lay-out in Vim script commands I decided to take the easy way out and use :mksession since it does this flawlessly already! But then I found a problem in the session script generated by :mksession. This is using the latest Vim 7.2 including patches 1-444.

The problem is that the session script includes an :args command that sets the argument list to one filename, which is fine, but then later the session script also executes the command "2argu" several times, which causes Vim to show the error "E163: There is only one file to edit" once for each occurrence of "2argu". I searched the archives for :mksession + E163 and found one previous thread about the same problem at http://old.nabble.com/session-problem-td27813363.html#a27814733 but that thread doesn't end with a solution.

I think I've found the cause to be a typo in ex_docmd.c where the expression wp->w_arg_idx <= WARGCOUNT(wp) should have been wp->w_arg_idx < WARGCOUNT(wp) (lower than instead of lower than or equal). After applying the attached patch and recompiling Vim I can no longer reproduce the problem described above, however I must admit that I failed to reliably reproduce the problem in the first place, it would just occur once in a while when I was testing my session plug-in.

 - Peter Odding
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -uNr vim-7.2/src/ex_docmd.c.old vim-7.2/src/ex_docmd.c
--- vim-7.2/src/ex_docmd.c.old	2010-06-25 18:49:45.583233458 +0200
+++ vim-7.2/src/ex_docmd.c	2010-06-25 18:49:48.082744150 +0200
@@ -10398,7 +10398,7 @@
 
     /* Only when part of a session: restore the argument index.  Some
      * arguments may have been deleted, check if the index is valid. */
-    if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx <= WARGCOUNT(wp)
+    if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx < WARGCOUNT(wp)
 						      && flagp == &ssop_flags)
     {
 	if (fprintf(fd, "%ldargu", (long)wp->w_arg_idx + 1) < 0

Raspunde prin e-mail lui