Sublime Forum

Find closing brackets

#1

Hi

Why it cant find closing/opening brackets

Code example
https://pastebin.com/MT6hBi3R

0 Likes

#2

They are parentheses across different strings.

0 Likes

#3

Dont understand what you mean?

0 Likes

#4

I mean there are 3 strings and you want parentheses in string 1 (yellow) to match parentheses in string 3 (red). I am not saying it’s not possible but that makes more problems than it solves, probably.

For example, given ("("), should the ( in "(" matches )? No.

1 Like

#5

Yes you write this probem like this.

Code for example its wrong syntax?
Whats write syntax?

     $pagination=pagination("
  SELECT 
  <fields> 
  FROM (".$sqlT.") as h 
  WHERE 1=1 ".$sql."
  ORDER BY ".$sort,
  "*",
  "COUNT(*) as n");

0 Likes

#6

Nothing wrong in your code grammatically (SQL injection welcome though). It’s just that ST won’t match parentheses across strings. If you want to workaround that badly in ST,

  • Find a way to write your strings into a single string such as
    • heredoc
    • string interpolation
  • Use an ORM. I guess you would’ve done already if you want and sometimes people still have to write raw SQL.
  • Invent your own ST plugin for whatever rules you want (like what BracketHighlighter plugin does). Sounds like a big effort for little gain but maybe this is actually easy idk.
  • Create a feature request ticket on GitHub. I don’t think it will be fulfilled officially though.
1 Like