comparison src/session.c @ 24473:b2484fa6cb02 v8.2.2776

patch 8.2.2776: :mksession uses current value of 'splitbelow' and 'splitright' Commit: https://github.com/vim/vim/commit/0995c81f2ffe276669daa004f7778ecc6f5ee09d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 17 18:38:54 2021 +0200 patch 8.2.2776: :mksession uses current value of 'splitbelow' and 'splitright' Problem: :mksession uses current value of 'splitbelow' and 'splitright' even though "options" is not in 'sessionoptions'. (Maxim Kim) Solution: Save and restore the values, instead of setting to the current value. (closes #8119)
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Apr 2021 18:45:04 +0200
parents a56f9c2ba51c
children f6049d3ab81c
comparison
equal deleted inserted replaced
24472:56a9d1063ba0 24473:b2484fa6cb02
777 777
778 // If no file got edited create an empty tab page. 778 // If no file got edited create an empty tab page.
779 if (need_tabnext && put_line(fd, "tabnext") == FAIL) 779 if (need_tabnext && put_line(fd, "tabnext") == FAIL)
780 goto fail; 780 goto fail;
781 781
782 // Save current window layout. 782 if (tab_topframe->fr_layout != FR_LEAF)
783 if (put_line(fd, "set splitbelow splitright") == FAIL) 783 {
784 goto fail; 784 // Save current window layout.
785 if (ses_win_rec(fd, tab_topframe) == FAIL) 785 if (put_line(fd, "let s:save_splitbelow = &splitbelow") == FAIL
786 goto fail; 786 || put_line(fd, "let s:save_splitright = &splitright")
787 if (!p_sb && put_line(fd, "set nosplitbelow") == FAIL) 787 == FAIL)
788 goto fail; 788 goto fail;
789 if (!p_spr && put_line(fd, "set nosplitright") == FAIL) 789 if (put_line(fd, "set splitbelow splitright") == FAIL)
790 goto fail; 790 goto fail;
791 if (ses_win_rec(fd, tab_topframe) == FAIL)
792 goto fail;
793 if (put_line(fd, "let &splitbelow = s:save_splitbelow") == FAIL
794 || put_line(fd, "let &splitright = s:save_splitright")
795 == FAIL)
796 goto fail;
797 }
791 798
792 // Check if window sizes can be restored (no windows omitted). 799 // Check if window sizes can be restored (no windows omitted).
793 // Remember the window number of the current window after restoring. 800 // Remember the window number of the current window after restoring.
794 nr = 0; 801 nr = 0;
795 for (wp = tab_firstwin; wp != NULL; wp = W_NEXT(wp)) 802 for (wp = tab_firstwin; wp != NULL; wp = W_NEXT(wp))
800 restore_size = FALSE; 807 restore_size = FALSE;
801 if (curwin == wp) 808 if (curwin == wp)
802 cnr = nr; 809 cnr = nr;
803 } 810 }
804 811
805 // Go to the first window. 812 if (tab_firstwin->w_next != NULL)
806 if (put_line(fd, "wincmd t") == FAIL) 813 {
807 goto fail; 814 // Go to the first window.
808 815 if (put_line(fd, "wincmd t") == FAIL)
809 // If more than one window, see if sizes can be restored. 816 goto fail;
810 // First set 'winheight' and 'winwidth' to 1 to avoid the windows being 817
811 // resized when moving between windows. 818 // If more than one window, see if sizes can be restored.
812 // Do this before restoring the view, so that the topline and the 819 // First set 'winheight' and 'winwidth' to 1 to avoid the windows
813 // cursor can be set. This is done again below. 820 // being resized when moving between windows.
814 // winminheight and winminwidth need to be set to avoid an error if the 821 // Do this before restoring the view, so that the topline and the
815 // user has set winheight or winwidth. 822 // cursor can be set. This is done again below.
816 if (put_line(fd, "set winminheight=0") == FAIL 823 // winminheight and winminwidth need to be set to avoid an error if
817 || put_line(fd, "set winheight=1") == FAIL 824 // the user has set winheight or winwidth.
818 || put_line(fd, "set winminwidth=0") == FAIL 825 if (put_line(fd, "let s:save_winminheight = &winminheight") == FAIL
819 || put_line(fd, "set winwidth=1") == FAIL) 826 || put_line(fd, "let s:save_winminwidth = &winminwidth")
820 goto fail; 827 == FAIL)
828 goto fail;
829 if (put_line(fd, "set winminheight=0") == FAIL
830 || put_line(fd, "set winheight=1") == FAIL
831 || put_line(fd, "set winminwidth=0") == FAIL
832 || put_line(fd, "set winwidth=1") == FAIL)
833 goto fail;
834 }
821 if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL) 835 if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL)
822 goto fail; 836 goto fail;
823 837
824 // Restore the tab-local working directory if specified 838 // Restore the tab-local working directory if specified
825 // Do this before the windows, so that the window-local directory can 839 // Do this before the windows, so that the window-local directory can
917 931
918 // Re-apply 'winheight', 'winwidth' and 'shortmess'. 932 // Re-apply 'winheight', 'winwidth' and 'shortmess'.
919 if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s", 933 if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
920 p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL) 934 p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL)
921 goto fail; 935 goto fail;
922 // Re-apply 'winminheight' and 'winminwidth'. 936 if (tab_firstwin->w_next != NULL)
923 if (fprintf(fd, "set winminheight=%ld winminwidth=%ld", 937 {
924 p_wmh, p_wmw) < 0 || put_eol(fd) == FAIL) 938 // Restore 'winminheight' and 'winminwidth'.
925 goto fail; 939 if (put_line(fd, "let &winminheight = s:save_winminheight") == FAIL
940 || put_line(fd, "let &winminwidth = s:save_winminwidth") == FAIL)
941 goto fail;
942 }
926 943
927 // Lastly, execute the x.vim file if it exists. 944 // Lastly, execute the x.vim file if it exists.
928 if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL 945 if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
929 || put_line(fd, "if filereadable(s:sx)") == FAIL 946 || put_line(fd, "if filereadable(s:sx)") == FAIL
930 || put_line(fd, " exe \"source \" . fnameescape(s:sx)") == FAIL 947 || put_line(fd, " exe \"source \" . fnameescape(s:sx)") == FAIL