Tracker: Patches

5 Bracket matching enhancements: <angle brackets> and other. - ID: 1849215
Last Update: Comment added ( ezust )

(1) Very simply patch: One thing to consider is the enforcement that the cursor must be to the *right* of the bracket for it to be matched. While this is the only way to resolve ambiguity in the case where there is a bracket on either side of the cursor, what if there is a bracket on only the right side of the cursor? Then this enforcement becomes a bit annoying, does it not? Path: In TextUtilities.java's findMatchingBracket() method, replace

return -1;

with

return findMatchingBracket(buffer,line,offset+1);

inside the "if(cprime == '\0')" condition.

(2) Another very simple patch, no explanation necessary. Just add < and > to the list of {([ and })] in TextUtilities.java. Problem solved.


encorejane ( encorejane ) - 2007-12-12 01:35:12 PST

5

Closed

Accepted

Alan Ezust

None

None

Public


Comments ( 4 )

Date: 2008-09-11 18:25:45 PDT
Sender: ezustProject AdminAccepting Donations

I actually don't use the built in action, since I use the XML plugin all
the time, and it has its own match tag or bracket which I prefer, which has
some overlap with this patch.

however, there are bugs from the recursion.
If you try to find a matching bracket that is nowhere near a bracket, such
as near the beginning or end of the file, you can sometimes get into
infinite recursion. So I rejected that part of the patch. But we do have
angle brackets.

IN the xml plugin,. with find matching tag or bracket, it does check both
sides of the cursor. If you can make your patch non-recursive, and test it
on boundary conditions, feel free to submit another patch.




java.lang.ArrayIndexOutOfBoundsException: 37:37
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:114)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.TextUtilities.findMatchingBracket(TextUtilities.java:130)
at
org.gjt.sp.jedit.textarea.TextArea.goToMatchingBracket(TextArea.java:3183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


Please fix it and re-submit.



Date: 2008-04-20 17:17:29 PDT
Sender: ezustProject AdminAccepting Donations


One thing I thought of, is that the way you rewrote findMatchingBracket is
recursive, so in the event that there is no bracket immediately to the
left, and no bracket to the right, findMatchingBracket will keep going to
the right of the cursor, until the end of the file. We may only want it to
go one character to the right and give up, don't you think?




Date: 2008-02-25 12:38:24 PST
Sender: encorejane


Thanks, I wasn't aware of the proper method of submitting a patch. I've
attached the patch file.
File Added: bracket_matching.patch


Date: 2008-02-24 21:26:32 PST
Sender: ezustProject AdminAccepting Donations


This is not a patch, but a bunch of suggestions. Please check out a copy
from SVN, apply your changes, and submit a patch generated with 'svn diff'
thanks for your contribution.



Attached File ( 1 )

Filename Description Download
bracket_matching.patch svn diff for the changes described above Download

Changes ( 5 )

Field Old Value Date By
status_id Open 2008-09-11 18:25:45 PDT ezust
resolution_id None 2008-09-11 18:25:45 PDT ezust
close_date - 2008-09-11 18:25:45 PDT ezust
File Added 267959: bracket_matching.patch 2008-02-25 12:38:24 PST encorejane
assigned_to nobody 2008-02-24 21:26:33 PST ezust