To: =?iso-8859-2?Q?Hanu=B9_Adler?= Cc: vim-dev@vim.org Subject: patch 5.4.12 (was: bug in vim) In-Reply-To: <19990802095423.A6296@dwarf.articon.cz> Fcc: outbox From: Bram Moolenaar ------------ Hanus Adler wrote: > it seems that the smartindent feature does not work properly in vim 5.4. > It did work in 5.3. Now when I have both smartindent on and autoindent > on, vim does not insert TABs as described in the manual on a new line > when the previous line ends in {. Also, it does not insert the TABs when > I am on a line ending in } and open a new line with O. Only when I > insert TABs manually or when the { is preceded by TAB, it seems to work, > but rather illogically. I found out about it when I tried to write some > perl script, but then I tested it on a non-perl file and it was the > same. > > I have checked that > +smartindent is compiled in vim > smartindent is on > autoindent is on or off > cindent is off I can reproduce it, but only when the current line has zero indent. After some debugging, discovered that there is a misplace 'else'. This is because the code to set "trunc_line" was moved upwards. Thus now the 'else' was paired with the wrong 'if'. Let's make a patch for this. Patch 5.4.12 Problem: When using 'smartindent', there would be no extra indent if the current line did not have any indent already. (Hanus Adler) Solution: There was a wrongly placed "else", that previously matched with the "if" that set trunc_line. Removed the "else" and added a check for trunc_line to be false. Files: src/misc1.c *** ../vim-5.4/src/misc1.c Sun Jul 25 22:02:07 1999 --- src/misc1.c Tue Aug 3 13:15:04 1999 *************** *** 290,297 **** * don't add an indent. Fixes inserting a NL before '{' in line * "if (condition) {" */ ! else if (curbuf->b_p_si && *saved_line != NUL && ! (p_extra == NULL || first_char != '{')) { char_u *ptr; char_u last_char; --- 290,297 ---- * don't add an indent. Fixes inserting a NL before '{' in line * "if (condition) {" */ ! if (!trunc_line && curbuf->b_p_si && *saved_line != NUL ! && (p_extra == NULL || first_char != '{')) { char_u *ptr; char_u last_char; *** ../vim-5.4/src/version.h Sat Jul 31 16:29:33 1999 --- src/version.h Tue Aug 3 13:19:47 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 11 ! #define VIM_VERSION_PATCHLEVEL_STR "11" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 12 ! #define VIM_VERSION_PATCHLEVEL_STR "12" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.11" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.11 (1999 Jul 31)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.11 (1999 Jul 31, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.12" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.12 (1999 Aug 3)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.12 (1999 Aug 3, compiled " -- BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One. ANOTHER MONK: And St. Attila raised his hand grenade up on high saying "O Lord bless this thy hand grenade that with it thou mayest blow thine enemies to tiny bits, in thy mercy. "and the Lord did grin and people did feast upon the lambs and sloths and carp and anchovies and orang-utans and breakfast cereals and fruit bats and... BROTHER MAYNARD: Skip a bit brother ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /