From: V. R. <vr...@se...> - 2005-07-05 18:10:23
|
Hi, Peter The bug: when the point(dot) is just before a closing parenthesis it is =20 ignored and _movePastCloseAndReindent_ passes 2 parenthesis and then =20 reindents. Basically it looks like this (a (b<cursor>)) --> (a (b <cursor>)) (a (b<cursor> )) --- (a (b ) <cursor>) and this may be a quick fix (and indeed is) diff -rN old-j-0.21.4/src/org/armedbear/j/Editor.java \ new-j-0.21.4/src/org/armedbear/j/Editor.java 6762,6769c6762,6774 < while (pos.next()) { < char c =3D pos.getChar(); < if (c =3D=3D '(') < ++count; < else if (c =3D=3D ')') < --count; < if (count =3D=3D 0) < break; --- > if (pos.getChar() =3D=3D ')') { > // found > count =3D 0; > } else { > while (pos.next()) { > char c =3D pos.getChar(); > if (c =3D=3D '(') > ++count; > else if (c =3D=3D ')') > --count; > if (count =3D=3D 0) > break; > } 6770a6776 >=20 Still _movePastCloseAndReindent_, IMHO remains broken but in a more =20 subtle way. Invoking repeatedly movePast... from the most nested form =20 in this expr: (a (b (c (d)))) gives us: (a (b (c (d) ) ) ) Since I given that matter a bit of thought I guess it can done like =20 this. Pseudocode follows: if (<lastCommand was movePastCloseAndReindent>) { <Undo> globalParenCount++; } else { globalParenCount =3D 1; } count =3D globalParentCount; <find count-th closing parenthesis> <new line and indent> In my "mental model" of J, it does the right thing. YMMV. Regards -- vasile |