gkz / grasp

JavaScript structural search, replace, and refactor
http://graspjs.com
MIT License
1.28k stars 33 forks source link

Maximum call stack size exceeded in large replacement #118

Closed adros closed 7 years ago

adros commented 7 years ago

This line in replace.ls

input-lines.splice start-line-num, number-of-lines, ...replace-lines

compiled as

inputLines.splice.apply(inputLines, [startLineNum, numberOfLines].concat(slice$.call(replaceLines)))

causes error, when replaceLines is large array. In this case splice is called with too many arguments (see https://stackoverflow.com/questions/22747068/is-there-a-max-number-of-arguments-javascript-functions-can-accept/22747272#22747272)

This issue has appeared when we were trying to do some heavy replacement in file with 134k lines. I will create a pull request that should fix this.