# Eliminate uneccesary calls to isRangeCommentedOrString #346

Merged
merged 1 commit into from Mar 20, 2018

## Conversation

Projects
None yet
2 participants
Contributor

### Requirements

• Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
• All new code requires tests to ensure against regressions

### Description of the Change

Fixes #341.

By design, brackets inside strings or comments are not matched. The previous behavior was that when the cursor was next to any bracket, even a bracket inside a comment or string, a search was performed for that bracket's closing pair. That search passes over comment or string scopes, so if a line read "(example words [cursor here])", bracket-manager would search the entire document and ultimately fail to find a match for the last ), even though it should not have performed the search in the first place. This PR simply stops bracket-manager from performing these searches when the bracket in question is in a comment or string scope.

### Alternate Designs

Do match brackets inside strings and comments. This has already been shown to be a bad idea.

### Benefits

Much faster performance in large files with many brackets. For instance, in language-latex, the following is considered a string scope: $here is some math$ so in a long document with lots of braces (almost any medium/long math paper fits this description), either of the following, or anything similar, would cause significant lag:
$\frac{numerator}{demonimator[cursor here]}$
$\sum_{n=1[cursor here]}^\infty n$.

None.

### Applicable Issues

 🐎 Eliminate uneccesary calls to isRangeCommentedOrString 
 8bbfbb8 

Member

### smashwilson commented Mar 20, 2018

 👍 Nice.

### smashwilson merged commit f4511d6 into atom:master Mar 20, 2018 2 checks passed

#### 2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Closed