To: vim_dev@googlegroups.com Subject: Patch 8.2.1904 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1904 Problem: Still using default option values after using ":badd +1". Solution: Find a window where options were set. Don't set the window when using ":badd". Files: src/buffer.c, src/ex_cmds.c, src/vim.h, src/testdir/test_buffer.vim *** ../vim-8.2.1903/src/buffer.c 2020-10-24 20:49:37.490683063 +0200 --- src/buffer.c 2020-10-25 17:08:24.529220430 +0100 *************** *** 1974,1980 **** { vim_free(ffname); if (lnum != 0) ! buflist_setfpos(buf, curwin, lnum, (colnr_T)0, FALSE); if ((flags & BLN_NOOPT) == 0) // copy the options now, if 'cpo' doesn't have 's' and not done --- 1974,1981 ---- { vim_free(ffname); if (lnum != 0) ! buflist_setfpos(buf, (flags & BLN_NOCURWIN) ? NULL : curwin, ! lnum, (colnr_T)0, FALSE); if ((flags & BLN_NOOPT) == 0) // copy the options now, if 'cpo' doesn't have 's' and not done *************** *** 2908,2914 **** void buflist_setfpos( buf_T *buf, ! win_T *win, linenr_T lnum, colnr_T col, int copy_options) --- 2909,2915 ---- void buflist_setfpos( buf_T *buf, ! win_T *win, // may be NULL when using :badd linenr_T lnum, colnr_T col, int copy_options) *************** *** 2950,2956 **** wip->wi_fpos.lnum = lnum; wip->wi_fpos.col = col; } ! if (copy_options) { // Save the window-specific option values. copy_winopt(&win->w_onebuf_opt, &wip->wi_opt); --- 2951,2957 ---- wip->wi_fpos.lnum = lnum; wip->wi_fpos.col = col; } ! if (copy_options && win != NULL) { // Save the window-specific option values. copy_winopt(&win->w_onebuf_opt, &wip->wi_opt); *************** *** 2997,3002 **** --- 2998,3004 ---- /* * Find info for the current window in buffer "buf". * If not found, return the info for the most recently used window. + * When "need_options" is TRUE skip entries where wi_optset is FALSE. * 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. *************** *** 3004,3009 **** --- 3006,3012 ---- static wininfo_T * find_wininfo( buf_T *buf, + int need_options, int skip_diff_buffer UNUSED) { wininfo_T *wip; *************** *** 3013,3030 **** #ifdef FEAT_DIFF && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) #endif ! ) break; // 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_ALL_BUF_WININFO(buf, wip) ! if (!wininfo_other_tab_diff(wip)) break; } else --- 3016,3040 ---- #ifdef FEAT_DIFF && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) #endif ! ! && (!need_options || wip->wi_optset)) break; // If no wininfo for curwin, use the first in the list (that doesn't have // 'diff' set and is in another tab page). + // If "need_options" is TRUE skip entries that don't have options set, + // unless the window is editing "buf", so we can copy from the window + // itself. if (wip == NULL) { #ifdef FEAT_DIFF if (skip_diff_buffer) { FOR_ALL_BUF_WININFO(buf, wip) ! if (!wininfo_other_tab_diff(wip) ! && (!need_options || wip->wi_optset ! || (wip->wi_win != NULL ! && wip->wi_win->w_buffer == buf))) break; } else *************** *** 3050,3056 **** clearFolding(curwin); #endif ! wip = find_wininfo(buf, TRUE); if (wip != NULL && wip->wi_win != NULL && wip->wi_win != curwin && wip->wi_win->w_buffer == buf) { --- 3060,3066 ---- clearFolding(curwin); #endif ! wip = find_wininfo(buf, TRUE, TRUE); if (wip != NULL && wip->wi_win != NULL && wip->wi_win != curwin && wip->wi_win->w_buffer == buf) { *************** *** 3097,3103 **** wininfo_T *wip; static pos_T no_position = {1, 0, 0}; ! wip = find_wininfo(buf, FALSE); if (wip != NULL) return &(wip->wi_fpos); else --- 3107,3113 ---- wininfo_T *wip; static pos_T no_position = {1, 0, 0}; ! wip = find_wininfo(buf, FALSE, FALSE); if (wip != NULL) return &(wip->wi_fpos); else *** ../vim-8.2.1903/src/ex_cmds.c 2020-10-25 15:02:47.955867035 +0100 --- src/ex_cmds.c 2020-10-25 16:52:04.391586525 +0100 *************** *** 2640,2646 **** if (tlnum <= 0) tlnum = 1L; } ! (void)buflist_new(ffname, sfname, tlnum, BLN_LISTED); goto theend; } buf = buflist_new(ffname, sfname, 0L, --- 2640,2649 ---- if (tlnum <= 0) tlnum = 1L; } ! // Add BLN_NOCURWIN to avoid a new wininfo items is assocated ! // with the current window. ! (void)buflist_new(ffname, sfname, tlnum, ! BLN_LISTED | BLN_NOCURWIN); goto theend; } buf = buflist_new(ffname, sfname, 0L, *** ../vim-8.2.1903/src/vim.h 2020-10-21 20:58:47.710889972 +0200 --- src/vim.h 2020-10-25 16:53:14.491433218 +0100 *************** *** 931,936 **** --- 931,937 ---- #define BLN_NOOPT 16 // don't copy options to existing buffer #define BLN_DUMMY_OK 32 // also find an existing dummy buffer #define BLN_REUSE 64 // may re-use number from buf_reuse + #define BLN_NOCURWIN 128 // buffer is not associated with curwin // Values for in_cinkeys() #define KEY_OPEN_FORW 0x101 *** ../vim-8.2.1903/src/testdir/test_buffer.vim 2020-10-25 16:18:23.434921227 +0100 --- src/testdir/test_buffer.vim 2020-10-25 16:24:49.501572786 +0100 *************** *** 366,372 **** new SomeNewBuffer setlocal numberwidth=3 wincmd p ! badd SomeNewBuffer new SomeNewBuffer call assert_equal(3, &numberwidth) close --- 366,372 ---- new SomeNewBuffer setlocal numberwidth=3 wincmd p ! badd +1 SomeNewBuffer new SomeNewBuffer call assert_equal(3, &numberwidth) close *** ../vim-8.2.1903/src/version.c 2020-10-25 16:18:23.434921227 +0100 --- src/version.c 2020-10-25 16:59:26.106566230 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1904, /**/ -- hundred-and-one symptoms of being an internet addict: 128. You can access the Net -- via your portable and cellular phone. /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///