To: vim-dev@vim.org Subject: Patch 6.3b.007 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3b.007 Problem: Session file doesn't restore view on windows properly. (Robert Webb) Solution: Restore window sizes both before and after restoring the view, so that the view, cursor position and size are restored properly. Files: src/ex_docmd.c *** ../vim-6.3b.006/src/ex_docmd.c Sun May 16 22:38:42 2004 --- src/ex_docmd.c Wed May 26 17:44:00 2004 *************** *** 8544,8549 **** --- 8547,8553 ---- #endif #ifdef FEAT_SESSION + static int ses_winsizes __ARGS((FILE *fd, int restore_size)); static int ses_win_rec __ARGS((FILE *fd, frame_T *fr)); static frame_T *ses_skipframe __ARGS((frame_T *fr)); static int ses_do_frame __ARGS((frame_T *fr)); *************** *** 8714,8722 **** --- 8718,8730 ---- * If more than one window, see if sizes can be restored. * First set 'winheight' and 'winwidth' to 1 to avoid the windows being * resized when moving between windows. + * Do this before restoring the view, so that the topline and the cursor + * can be set. This is done again below. */ if (put_line(fd, "set winheight=1 winwidth=1") == FAIL) return FAIL; + if (nr > 1 && ses_winsizes(fd, restore_size) == FAIL) + return FAIL; /* * Restore the view of the window (options, file, cursor, etc.). *************** *** 8738,8781 **** return FAIL; /* ! * Restore window sizes. Do this after jumping around in windows, because ! * the current window has a minimum size while others may not. */ ! if (nr > 1) ! { ! if (restore_size && (ssop_flags & SSOP_WINSIZE)) ! { ! int n = 0; ! ! for (wp = firstwin; wp != NULL; wp = wp->w_next) ! { ! if (!ses_do_win(wp)) ! continue; ! ++n; ! ! /* restore height when not full height */ ! if (wp->w_height + wp->w_status_height < topframe->fr_height ! && (fprintf(fd, ! "exe '%dresize ' . ((&lines * %ld + %ld) / %ld)", ! n, (long)wp->w_height, Rows / 2, Rows) < 0 ! || put_eol(fd) == FAIL)) ! return FAIL; ! ! /* restore width when not full width */ ! if (wp->w_width < Columns && (fprintf(fd, ! "exe 'vert %dresize ' . ((&columns * %ld + %ld) / %ld)", ! n, (long)wp->w_width, Columns / 2, Columns) < 0 ! || put_eol(fd) == FAIL)) ! return FAIL; ! } ! } ! else ! { ! /* Just equalise window sizes */ ! if (put_line(fd, "wincmd =") == FAIL) ! return FAIL; ! } ! } /* Re-apply 'winheight', 'winwidth' and 'shortmess'. */ if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s", --- 8746,8756 ---- return FAIL; /* ! * Restore window sizes again after jumping around in windows, because the ! * current window has a minimum size while others may not. */ ! if (nr > 1 && ses_winsizes(fd, restore_size) == FAIL) ! return FAIL; /* Re-apply 'winheight', 'winwidth' and 'shortmess'. */ if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s", *************** *** 8791,8796 **** --- 8766,8812 ---- || put_line(fd, "endif") == FAIL) return FAIL; + return OK; + } + + static int + ses_winsizes(fd, restore_size) + FILE *fd; + int restore_size; + { + int n = 0; + win_T *wp; + + if (restore_size && (ssop_flags & SSOP_WINSIZE)) + { + for (wp = firstwin; wp != NULL; wp = wp->w_next) + { + if (!ses_do_win(wp)) + continue; + ++n; + + /* restore height when not full height */ + if (wp->w_height + wp->w_status_height < topframe->fr_height + && (fprintf(fd, + "exe '%dresize ' . ((&lines * %ld + %ld) / %ld)", + n, (long)wp->w_height, Rows / 2, Rows) < 0 + || put_eol(fd) == FAIL)) + return FAIL; + + /* restore width when not full width */ + if (wp->w_width < Columns && (fprintf(fd, + "exe 'vert %dresize ' . ((&columns * %ld + %ld) / %ld)", + n, (long)wp->w_width, Columns / 2, Columns) < 0 + || put_eol(fd) == FAIL)) + return FAIL; + } + } + else + { + /* Just equalise window sizes */ + if (put_line(fd, "wincmd =") == FAIL) + return FAIL; + } return OK; } *** ../vim-6.3b.006/src/version.c Wed May 26 17:17:08 2004 --- src/version.c Wed May 26 18:32:17 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 7, /**/ -- If your company is not involved in something called "ISO 9000" you probably have no idea what it is. If your company _is_ involved in ISO 9000 then you definitely have no idea what it is. (Scott Adams - The Dilbert principle) /// 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 ///