Jason Franklin wrote:

> This patch just simplifies the code for outputting the
> ":tabnew" commands that a session script should invoke.
> Currently, the code is a bit messy and was easy to
> simplify:
> 
> 
> diff --git a/src/ex_docmd.c b/src/ex_docmd.c
> index 8a9b2f4bf..91314ec2a 100644
> --- a/src/ex_docmd.c
> +++ b/src/ex_docmd.c
> @@ -11401,26 +11401,17 @@ makeopens(
>      tab_topframe = topframe;
>      if ((ssop_flags & SSOP_TABPAGES))
>      {
> -     int     num_tabs;
> +     tabpage_T *tp;
>  
> -     /*
> -      * Similar to ses_win_rec() below, populate the tab pages first so
> -      * later local options won't be copied to the new tabs.
> -      */
> -     for (tabnr = 1; ; ++tabnr)
> +     // This is similar to "ses_win_rec()" below.  Populate the tab pages
> +     // first so that local options won't be copied to new tabs later.
> +     FOR_ALL_TABPAGES(tp)
>       {
> -         tabpage_T *tp = find_tabpage(tabnr);
> -
> -         if (tp == NULL)     /* done all tab pages */
> -             break;
> -
> -         if (tabnr > 1 && put_line(fd, "tabnew") == FAIL)
> +         if (tp->tp_next != NULL && put_line(fd, "tabnew") == FAIL)
>               return FAIL;
>       }
>  
> -     num_tabs = tabnr - 1;
> -     if (num_tabs > 1 && (fprintf(fd, "tabnext -%d", num_tabs - 1) < 0
> -                                                    || put_eol(fd) == FAIL))
> +     if (first_tabpage->tp_next != NULL && put_line(fd, "tabnext 1") == FAIL)
>           return FAIL;
>      }
>      for (tabnr = 1; ; ++tabnr)
> 
> 
> All of the existing tests for mksession still pass.
> 
> Let me know if anything looks amiss.

Yeah, that was convoluted code.  It can be simplified a bit more by
using "tabrewind" at the end.

-- 
This is an airconditioned room, do not open Windows.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui