A few coding hours in the train later, I've added new features to the structure matcher for R scripts. Basically I've been working to improve the matching of closing curly brackets in particular cases. This is how it proceeds: when you close a curly bracket, it looks for the corresponding opening bracket (thanks to the TextUtilities class), then looks if there is a closing round bracket just before, finds the matching opening round bracket, identifies which word is before. Then

  • if this word is one of if, for, while, repeat or function the macth is considered to start from the word up to the closing curly bracket
  • Otherwise, the match is just the closing curly bracket as usual

... but it is probably better to show some screenshots to get a better idea:

Screenshot-1.png

Screenshot-2.png

Screenshot-3.png

Screenshot-4.png

Screenshot-5.png

Screenshot-6.png

Screenshot-7.png