Bracket Pair Matching Buggy?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Bracket Pair Matching Buggy?

Postby Kuriel » Fri Mar 22, 2013 1:28 pm

Hi,

IDK if I coded a bug into the RSTA source or not, but I checked out revision 754 and found a bug. If you put in a pair (e.g. {}) as the only entry in the text area:

1. Going to the left of the opening curly does not highlight the pair if there are no spaces before the opening curly
2. If there are spaces before the opening curly, the highlights would be on the space/character preceding the opening curly and the closing curly; if coming from the left. If coming from the right, the highlights would be on the opening curly and the space/character preceding the closing curly.
3. Going in between the brackets and hitting space will also show erroneous highlighting.

Thank you.
Kuriel
 
Posts: 14
Joined: Thu Nov 29, 2012 6:24 am

Re: Bracket Pair Matching Buggy?

Postby Kuriel » Sun Mar 31, 2013 3:40 am

Hi Robert,

I had a little off-time so I was able to look at the source. I was able to fix the bracket matching though I'm pretty sure it could be done more elegantly :lol:. Anyway, thanks for any effort you took looking into this and also for putting the feature I requested in. It now works great!

Edit:
Sorry, I should have put the details in earlier, so here it is. Since I'm sure you could find out a better fix, I'll just put in the section that was causing the problem:

  • In RSyntaxTextArea, under doBracketMatching, the part
    Code: Select all
                   if (getPaintMatchedBracketPair()) {
                      if (getCaretPosition()-1 != -1)
                         dotRect = modelToView(getCaretPosition()-1);
                   }


    was where I put a check on whether the character for dotRect was found before or after the caret. If it was before, I used the modelToView above. If it was after, I took off the -1

  • As for caretPosition == 0 (becoming -1), I put a *cough* hack in RSyntaxUtilities.getMatchingBracketPosition to still process the matching, doing doc.charAt(0) and setting the caretPosition to 0 to avoid the NPE downstream.

I hope this helps :)
Kuriel
 
Posts: 14
Joined: Thu Nov 29, 2012 6:24 am

Re: Bracket Pair Matching Buggy?

Postby robert » Sun Mar 31, 2013 11:41 pm

Thanks for reporting these issues. I believe I've fixed all 3 of them in revision 781 in SVN. Please try them out and let me know how they look.
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm

Re: Bracket Pair Matching Buggy?

Postby Kuriel » Mon Apr 01, 2013 2:57 am

Your fix looks and works great. Thanks for looking into this again :)
Kuriel
 
Posts: 14
Joined: Thu Nov 29, 2012 6:24 am


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron