diff options
author | Bram Moolenaar <Bram@vim.org> | 2008-11-15 13:12:07 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2008-11-15 13:12:07 +0000 |
commit | 701f7afcdf5f510090116a6a6fa91ca479c88e06 (patch) | |
tree | 608ff9b10fa5dbdb613f17f0242a160d19dacc13 /src/buffer.c | |
parent | 1c8603613a33f6012c7d7e0d9db02323f2e785b4 (diff) | |
download | vim-git-701f7afcdf5f510090116a6a6fa91ca479c88e06.tar.gz |
updated for version 7.2-041v7.2.041
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/src/buffer.c b/src/buffer.c index 7eb3d49a9..4104977d6 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -33,7 +33,7 @@ static char_u *buflist_match __ARGS((regprog_T *prog, buf_T *buf)); static char_u *fname_match __ARGS((regprog_T *prog, char_u *name)); #endif static void buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options)); -static wininfo_T *find_wininfo __ARGS((buf_T *buf)); +static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer)); #ifdef UNIX static buf_T *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st)); static int otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp)); @@ -1093,7 +1093,7 @@ do_buffer(action, start, dir, count, forceit) #endif setpcmark(); retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, - forceit ? ECMD_FORCEIT : 0); + forceit ? ECMD_FORCEIT : 0, curwin); /* * do_ecmd() may create a new buffer, then we have to delete @@ -1316,7 +1316,7 @@ set_curbuf(buf, action) setpcmark(); if (!cmdmod.keepalt) curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */ - buflist_altfpos(); /* remember curpos */ + buflist_altfpos(curwin); /* remember curpos */ #ifdef FEAT_VISUAL /* Don't restart Select mode after switching to another buffer. */ @@ -2404,22 +2404,70 @@ buflist_setfpos(buf, win, lnum, col, copy_options) return; } +#ifdef FEAT_DIFF +static int wininfo_other_tab_diff __ARGS((wininfo_T *wip)); + +/* + * Return TRUE when "wip" has 'diff' set and the diff is only for another tab + * page. That's because a diff is local to a tab page. + */ + static int +wininfo_other_tab_diff(wip) + wininfo_T *wip; +{ + win_T *wp; + + if (wip->wi_opt.wo_diff) + { + for (wp = firstwin; wp != NULL; wp = wp->w_next) + /* return FALSE when it's a window in the current tab page, thus + * the buffer was in diff mode here */ + if (wip->wi_win == wp) + return FALSE; + return TRUE; + } + return FALSE; +} +#endif + /* * Find info for the current window in buffer "buf". * If not found, return the info for the most recently used window. + * When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in + * another tab page. * Returns NULL when there isn't any info. */ +/*ARGSUSED*/ static wininfo_T * -find_wininfo(buf) +find_wininfo(buf, skip_diff_buffer) buf_T *buf; + int skip_diff_buffer; { wininfo_T *wip; for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) - if (wip->wi_win == curwin) + if (wip->wi_win == curwin +#ifdef FEAT_DIFF + && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) +#endif + ) break; - if (wip == NULL) /* if no fpos for curwin, use the first in the list */ - wip = buf->b_wininfo; + + /* If no wininfo for curwin, use the first in the list (that doesn't have + * 'diff' set and is in another tab page). */ + if (wip == NULL) + { +#ifdef FEAT_DIFF + if (skip_diff_buffer) + { + for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) + if (!wininfo_other_tab_diff(wip)) + break; + } + else +#endif + wip = buf->b_wininfo; + } return wip; } @@ -2440,7 +2488,7 @@ get_winopts(buf) clearFolding(curwin); #endif - wip = find_wininfo(buf); + wip = find_wininfo(buf, TRUE); if (wip != NULL && wip->wi_optset) { copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt); @@ -2472,7 +2520,7 @@ buflist_findfpos(buf) wininfo_T *wip; static pos_T no_position = {1, 0}; - wip = find_wininfo(buf); + wip = find_wininfo(buf, FALSE); if (wip != NULL) return &(wip->wi_fpos); else @@ -2793,14 +2841,14 @@ buflist_slash_adjust() #endif /* - * Set alternate cursor position for current window. + * Set alternate cursor position for the current buffer and window "win". * Also save the local window option values. */ void -buflist_altfpos() +buflist_altfpos(win) + win_T *win; { - buflist_setfpos(curbuf, curwin, curwin->w_cursor.lnum, - curwin->w_cursor.col, TRUE); + buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE); } /* @@ -4492,7 +4540,7 @@ do_arg_all(count, forceit, keep_tabs) ECMD_ONE, ((P_HID(curwin->w_buffer) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) - + ECMD_OLDBUF); + + ECMD_OLDBUF, curwin); #ifdef FEAT_AUTOCMD if (use_firstwin) ++autocmd_no_leave; |