Sublime Forum

Custom syntax was working fine on ST3, became laggy on ST4

#1

I have a custom syntax with the following minimal example:

contexts: 
  main:
    - match: '^↓$'
      set: highlight
  highlight:
    - match: '^$'
      pop: true

Basically, my entire file is split into blocks separated by empty lines, some of which are prefaced by a line with only “↓” on it, which marks that this block is “highlighted”. The file is fairly large, 250k lines and 25m characters.
When I was on ST3, everything was working smoothly. When I upgraded to ST4, making or deleting new lines and writing/erasing the first/only character in them at the start of* large highlight blocks started being accompanied by a several-second delay.
(*by “at the start” I really mean that the lag is most severe at the start and then gradually diminishes the lower you go and the fewer lines remain to the end of the block)

To reproduce:

  1. Use the syntax above.
  2. Create a new file that is nothing but 200k lines of 100 characters each.
  3. Add a line with only “↓” right before this chunk of text.
  4. Press enter after the “↓” (or at the end of any line at the start of the large block, so a new empty line is created)
  5. Result: a long lag.
  6. Type any symbol.
  7. Result: another long lag.
0 Likes

#2

We’ve got a fix for this in the works.

1 Like

#3

The syntax snippet contains a bug, IMHO. You should push highlight context instead of set it, because it is popped. The current solution tries to pop more contexts off stack than it contains. Some checks were added to prevent it. Maybe they cause some slowdowns.

0 Likes