From b5064a4bb38e24fdd74e1e4899f33b83e70fe1bc Mon Sep 17 00:00:00 2001 From: Scott Glajch Date: Wed, 25 Feb 2015 13:00:39 -0500 Subject: [PATCH] Fix for issue #2374, maximum call stack exceeded in 64 bit chrome when pasting large chunks. --- lib/ace/document.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ace/document.js b/lib/ace/document.js index 10a36eb2..0214b38b 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -311,11 +311,12 @@ var Document = function(text) { if (lines.length == 0) return {row: row, column: 0}; - // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) - // to circumvent that we have to break huge inserts into smaller chunks here - while (lines.length > 0xF000) { - var end = this._insertLines(row, lines.slice(0, 0xF000)); - lines = lines.slice(0xF000); + // Apply doesn't work for big arrays due to max call stack detection. + // Chrome 64 bit requires threshold smaller than 32k, using a safe value of 1k. + // To circumvent that we have to break huge inserts into smaller chunks here. + while (lines.length > 1000) { + var end = this._insertLines(row, lines.slice(0, 1000)); + lines = lines.slice(1000); row = end.row; }