Skip to content
Permalink
Browse files

Merge pull request #17792 from atom/mb-tree-sitter-stack-overflow

Avoid stack overflows due to spread args in Array.splice call
  • Loading branch information...
maxbrunsfeld committed Aug 6, 2018
2 parents 29ef7d7 + fce7360 commit e467de023edda15997b0155f647c7b08a18050c8
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/tree-sitter-language-mode.js
@@ -1,5 +1,5 @@
const Parser = require('tree-sitter')
const {Point, Range} = require('text-buffer')
const {Point, Range, spliceArray} = require('text-buffer')
const {Patch} = require('superstring')
const {Emitter, Disposable} = require('event-kit')
const ScopeDescriptor = require('./scope-descriptor')
@@ -52,10 +52,11 @@ class TreeSitterLanguageMode {
this.subscription = this.buffer.onDidChangeText(({changes}) => {
for (let i = 0, {length} = changes; i < length; i++) {
const {oldRange, newRange} = changes[i]
this.isFoldableCache.splice(
spliceArray(
this.isFoldableCache,
newRange.start.row,
oldRange.end.row - oldRange.start.row,
...new Array(newRange.end.row - newRange.start.row)
{length: newRange.end.row - newRange.start.row}
)
}

0 comments on commit e467de0

Please sign in to comment.
You can’t perform that action at this time.