[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim-dev
Subject:    RE: Session file problems.
From:       Bram Moolenaar <Bram () moolenaar ! net>
Date:       2004-05-28 13:24:49
Message-ID: 200405281324.i4SDOndx009955 () moolenaar ! net
[Download RAW message or body]


Robert Webb wrote:

> > > (2) I also noticed recently that my top window was being replaced
> > > by a different file after reloading a session.  The file it got
> > > replaced with was the first file in my :args list, which didn't
> > > appear in any window when the session was saved.  But I can't seem
> > > to reproduce this now.
> > 
> > Can't guess why it happened.  Perhaps because the file was no longer
> > available and loading it failed?
> 
> The files were all available... Ah, I've figured it out!
> It happens when the current file in the args list is not the file
> actually loaded, but only in the top window.  I guess this is a
> consequence of that last unofficial patch you sent me (did that become
> official by the way?  I didn't notice it).
> 
> Attached is another test setup.  When saving the session the three
> windows were:

I can reproduce the problem.  It happens when a file is loaded before
splitting windows, and the first window is not editing the file at the
current position in the argument list.  There is the wrong assumption
that the file areadly is being edited, but a ":2next" command is used to
set the position in the argument list, which is another file.

The patch below should fix this.  This also avoids that a file is read
twice when ":2next" edits the same file that the next ":edit" does.


*** ../vim-6.3b.007/src/ex_docmd.c	Wed May 26 18:48:19 2004
--- src/ex_docmd.c	Fri May 28 14:58:15 2004
***************
*** 8675,8681 ****
  	    if (fputs("edit ", fd) < 0
  		    || ses_fname(fd, wp->w_buffer, &ssop_flags) == FAIL)
  		return FAIL;
! 	    edited_win = wp;
  	    break;
  	}
      }
--- 8678,8685 ----
  	    if (fputs("edit ", fd) < 0
  		    || ses_fname(fd, wp->w_buffer, &ssop_flags) == FAIL)
  		return FAIL;
! 	    if (!wp->w_arg_idx_invalid)
! 		edited_win = wp;
  	    break;
  	}
      }
***************
*** 8956,8962 ****
  	    return FAIL;
      }
  
!     if (add_edit)
      {
  	/*
  	 * Load the file.
--- 8960,8967 ----
  	    return FAIL;
      }
  
!     if (add_edit && (wp->w_arg_idx == 0 || flagp != &ssop_flags
! 						    || wp->w_arg_idx_invalid))
      {
  	/*
  	 * Load the file.


-- 
An alien life briefly visits earth.  Just before departing it leaves a
message in the dust on the back of a white van.  The world is shocked
and wants to know what it means.  After months of studies the worlds
best linguistic scientists are able to decipher the message: "Wash me!".

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic