To: vim_dev@googlegroups.com Subject: Patch 8.2.3754 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3754 (after 8.2.3615) Problem: Undesired changing of the indent of the first formatted line. Solution: Do not indent the first formatted line. Files: src/textformat.c, src/testdir/test_indent.vim *** ../vim-8.2.3753/src/textformat.c 2021-11-18 13:56:33.603725506 +0000 --- src/textformat.c 2021-12-06 18:05:32.723550030 +0000 *************** *** 954,959 **** --- 954,960 ---- int smd_save; long count; int need_set_indent = TRUE; // set indent of next paragraph + linenr_T first_line = curwin->w_cursor.lnum; int force_format = FALSE; int old_State = State; *************** *** 1073,1080 **** { int indent = 0; // amount of indent needed ! // replace indent in first line with minimal number of ! // tabs and spaces, according to current options # ifdef FEAT_LISP if (curbuf->b_p_lisp) indent = get_lisp_indent(); --- 1074,1086 ---- { int indent = 0; // amount of indent needed ! // Replace indent in first line of a paragraph with minimal ! // number of tabs and spaces, according to current options. ! // For the very first formatted line keep the current ! // indent. ! if (curwin->w_cursor.lnum == first_line) ! indent = get_indent(); ! else # ifdef FEAT_LISP if (curbuf->b_p_lisp) indent = get_lisp_indent(); *** ../vim-8.2.3753/src/testdir/test_indent.vim 2021-11-18 13:56:33.603725506 +0000 --- src/testdir/test_indent.vim 2021-12-06 19:44:53.151971593 +0000 *************** *** 172,178 **** \ 'metus lectus ultrices odio, sed elementum mi ante at arcu.', '', '\begin{center}', '', \ 'Proin nec risus consequat nunc dapibus consectetur. Mauris lacinia est a augue', \ 'tristique accumsan. Morbi pretium, felis molestie eleifend condimentum, arcu', ! \ 'ipsum congue nisl, quis euismod purus libero in ante. Donec id semper purus.', \ 'Suspendisse eget aliquam nunc. Maecenas fringilla mauris vitae maximus', \ 'condimentum. Cras a quam in mi dictum eleifend at a lorem. Sed convallis', \ 'ante a commodo facilisis. Nam suscipit vulputate odio, vel dapibus nisl', --- 172,179 ---- \ 'metus lectus ultrices odio, sed elementum mi ante at arcu.', '', '\begin{center}', '', \ 'Proin nec risus consequat nunc dapibus consectetur. Mauris lacinia est a augue', \ 'tristique accumsan. Morbi pretium, felis molestie eleifend condimentum, arcu', ! \ 'ipsum congue nisl, quis euismod purus libero in ante.', '', ! \ 'Donec id semper purus.', \ 'Suspendisse eget aliquam nunc. Maecenas fringilla mauris vitae maximus', \ 'condimentum. Cras a quam in mi dictum eleifend at a lorem. Sed convallis', \ 'ante a commodo facilisis. Nam suscipit vulputate odio, vel dapibus nisl', *************** *** 181,190 **** 1d_ call cursor(5, 1) ka ! call cursor(15, 1) kb norm! 'agqap ! norm! 'bgqap let expected = [ '\documentclass{article}', '', '\begin{document}', '', \ 'Lorem ipsum dolor sit amet, consectetur adipiscing', \ 'elit. Fusce ut enim non libero efficitur aliquet.', --- 182,191 ---- 1d_ call cursor(5, 1) ka ! call cursor(14, 1) kb norm! 'agqap ! norm! 'bgqG let expected = [ '\documentclass{article}', '', '\begin{document}', '', \ 'Lorem ipsum dolor sit amet, consectetur adipiscing', \ 'elit. Fusce ut enim non libero efficitur aliquet.', *************** *** 201,209 **** \ ' consectetur. Mauris lacinia est a augue', \ ' tristique accumsan. Morbi pretium, felis', \ ' molestie eleifend condimentum, arcu ipsum congue', ! \ ' nisl, quis euismod purus libero in ante. Donec', ! \ ' id semper purus. Suspendisse eget aliquam nunc.', ! \ ' Maecenas fringilla mauris vitae maximus', \ ' condimentum. Cras a quam in mi dictum eleifend', \ ' at a lorem. Sed convallis ante a commodo', \ ' facilisis. Nam suscipit vulputate odio, vel', --- 202,211 ---- \ ' consectetur. Mauris lacinia est a augue', \ ' tristique accumsan. Morbi pretium, felis', \ ' molestie eleifend condimentum, arcu ipsum congue', ! \ ' nisl, quis euismod purus libero in ante.', ! \ '', ! \ ' Donec id semper purus. Suspendisse eget aliquam', ! \ ' nunc. Maecenas fringilla mauris vitae maximus', \ ' condimentum. Cras a quam in mi dictum eleifend', \ ' at a lorem. Sed convallis ante a commodo', \ ' facilisis. Nam suscipit vulputate odio, vel', *************** *** 217,220 **** --- 219,246 ---- delfunction GetTeXIndent endfu + func Test_formatting_keeps_first_line_indent() + let lines =<< trim END + foo() + { + int x; // manually positioned + // more text that will be formatted + // but not reindented + END + new + call setline(1, lines) + setlocal sw=4 cindent tw=45 et + normal! 4Ggqj + let expected =<< trim END + foo() + { + int x; // manually positioned + // more text that will be + // formatted but not + // reindented + END + call assert_equal(expected, getline(1, '$')) + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3753/src/version.c 2021-12-06 15:06:49.335517805 +0000 --- src/version.c 2021-12-06 19:50:26.222736276 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3754, /**/ -- A consultant is a person who takes your money and annoys your employees while tirelessly searching for the best way to extend the consulting contract. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///