Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JavaScript] Fix ST freezing #4003

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

deathaxe
Copy link
Collaborator

Fixes sublimehq/sublime_text#6416

Regressed by #3836

This commit refactors for loop conditions to prevent ST's syntax engine to run into an infinite loop, if multiple nested for loops appear within branches, such as arrow functions.

The issue seems to be triggered by

  for-condition-contents:
    - match: ''
      branch_point: for-in-of
      branch:
        - for-in-of
        - for-oldstyle
      pop: 1

in conjunction with newlines.

Note: It somewhat reorganizes expressions contexts a little bit.

Fixes sublimehq/sublime_text#6416

Regressed by sublimehq#3836

This commit refactors for loop conditions to prevent ST's syntax engine to run
into an infinite loop, if multiple nested for loops appear within branches,
such as arrow functions.

The issue seems to be triggered by

```yml
  for-condition-contents:
    - match: ''
      branch_point: for-in-of
      branch:
        - for-in-of
        - for-oldstyle
      pop: 1
```

in conjunction with newlines.

Note: It somewhat reorganizes expressions contexts a little bit.
@Nefsen402
Copy link

I was able to confirm that this patch fixes the syntax highlighting errors for me. Thanks!

@deathaxe deathaxe merged commit 16c47e7 into sublimehq:master Jun 29, 2024
2 checks passed
@deathaxe deathaxe deleted the pr/javascript/fix-infinite-loop branch June 29, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sublime text spins CPU when trying to open specific javascript file
4 participants