-
Notifications
You must be signed in to change notification settings - Fork 97
[performance]: Low frame rate when the matching bracket spans several hundreds of lines #348
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
When trying to type in front of a bracket and the corresponding closing bracket is located several hundreds of lines later, the editor's frame rate drops significantly and typed characters appear almost half a second later.
Example code:
describe('test', () => {
// ^ start typing here with cursor in front of the opening (
// ... lots and lots of JS here (1200 SLOC)
})Steps to Reproduce
- Open a huge file (tested on JavaScript file with big test suite)
- Place the cursor in front of the opening bracket while the matching closing bracket is located several hundreds of lines later
- Attempt to type some characters
- Observe editor lag
Expected behavior: No editor lag, smooth typing experience, feelings of joy and happiness
Actual behavior: typed characters appear after several hundreds of ms, editor feels unresponsive, feelings of anger and frustration
Reproduces how often: 100% of the time, but only when the matching bracket is very very far away
Versions
Atom : 1.26.0-beta1
Electron: 1.7.11
Chrome : 58.0.3029.110
Node : 7.9.0
OS: MacOS 10.13.4
Additional Information
I am attaching Chrome's performance profile for further inspection. From the stack traces included there I concluded that this is likely a problem with the bracket-matcher package. Disabling the package resolves the issue described here.
I have not looked at the code at all, but it almost seems that bracket-matcher is searching for the matching bracket on each keystroke even though none of the brackets are actually modified, only the content in front of them. 🤔