To: vim-dev@vim.org Subject: Patch 6.1.207 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.207 Problem: Indenting a Java file hangs below a line with a comment after a command. Solution: Break out of a loop. (Andre Pang) Also line up } with matching {. Files: runtime/indent/java.vim *** ../vim61.206/runtime/indent/java.vim Sun May 12 18:48:10 2002 --- runtime/indent/java.vim Fri Oct 4 22:36:06 2002 *************** *** 1,7 **** " Vim indent file " Language: Java " Maintainer: Bram Moolenaar ! " Last Change: 2002 Apr 21 " Only load this indent file when no other was loaded. if exists("b:did_indent") --- 1,7 ---- " Vim indent file " Language: Java " Maintainer: Bram Moolenaar ! " Last Change: 2002 Oct 04 " Only load this indent file when no other was loaded. if exists("b:did_indent") *************** *** 30,36 **** let theIndent = cindent(v:lnum) " find start of previous line, in case it was a continuation line ! let prev = v:lnum - 1 while prev > 1 if getline(prev - 1) !~ ',\s*$' break --- 30,36 ---- let theIndent = cindent(v:lnum) " find start of previous line, in case it was a continuation line ! let prev = prevnonblank(v:lnum - 1) while prev > 1 if getline(prev - 1) !~ ',\s*$' break *************** *** 60,69 **** elseif prev == v:lnum - 1 let theIndent = theIndent + amount endif ! elseif getline(v:lnum - 1) =~ '^\s*throws\>' let theIndent = theIndent - &sw endif " Below a line starting with "}" never indent more. Needed for a method " below a method with an indented "throws" clause. " First ignore comment lines. --- 60,87 ---- elseif prev == v:lnum - 1 let theIndent = theIndent + amount endif ! elseif getline(prev) =~ '^\s*throws\>' let theIndent = theIndent - &sw endif + " When the line starts with a }, try aligning it with the matching {, + " skipping over "throws", "extends" and "implements" clauses. + if getline(v:lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$' + call cursor(v:lnum, 1) + silent normal % + let lnum = line('.') + if lnum < v:lnum + while lnum > 1 + if getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>' + \ && getline(prevnonblank(lnum - 1)) !~ ',\s*$' + break + endif + let lnum = prevnonblank(lnum - 1) + endwhile + return indent(lnum) + endif + endif + " Below a line starting with "}" never indent more. Needed for a method " below a method with an indented "throws" clause. " First ignore comment lines. *************** *** 76,81 **** --- 94,101 ---- endwhile if getline(lnum) =~ '^\s*/\*' let lnum = lnum - 1 + else + break endif elseif getline(lnum) =~ '^\s*//' let lnum = lnum - 1 *** ../vim61.206/src/version.c Tue Oct 1 20:20:25 2002 --- src/version.c Sun Oct 6 18:22:02 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 207, /**/ -- Never eat yellow snow. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///