From: Peter G. <pe...@ar...> - 2005-07-06 23:45:18
|
On Tue, 05 Jul 2005 at 18:10:30 +0000, V. Rotaru wrote: > Hi, Peter > > The bug: when the point(dot) is just before a closing parenthesis it is > ignored and _movePastCloseAndReindent_ passes 2 parenthesis and then > 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 = pos.getChar(); > < if (c == '(') > < ++count; > < else if (c == ')') > < --count; > < if (count == 0) > < break; > --- > > if (pos.getChar() == ')') { > > // found > > count = 0; > > } else { > > while (pos.next()) { > > char c = pos.getChar(); > > if (c == '(') > > ++count; > > else if (c == ')') > > --count; > > if (count == 0) > > break; > > } > 6770a6776 > > > > Still _movePastCloseAndReindent_, IMHO remains broken but in a more > subtle way. Invoking repeatedly movePast... from the most nested form > 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 > this. Pseudocode follows: > > if (<lastCommand was movePastCloseAndReindent>) { > <Undo> > globalParenCount++; > } else { > globalParenCount = 1; > } > count = globalParentCount; > <find count-th closing parenthesis> > <new line and indent> > > In my "mental model" of J, it does the right thing. YMMV. I've applied your "quick fix" patch, and I think I've also fixed the second problem you describe, although in a somewhat different way (once again, I didn't rely on undo, so it should work the same way even if movePastCloseAndReindent was not the last command). Please let me know how it works for you. Thanks for your help with this problem! -Peter |