From 2983c4b19f59f2d5e010764957e622ce22338674 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 5 Oct 2014 22:05:34 +0400 Subject: [PATCH] do not throw when trying to add intersecting folds --- lib/ace/edit_session/folding.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index a727b15a..0274cd58 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -289,13 +289,12 @@ function Folding() { if (startFold && endFold == startFold) return startFold.addSubFold(fold); - if ( - (startFold && !startFold.range.isStart(startRow, startColumn)) - || (endFold && !endFold.range.isEnd(endRow, endColumn)) - ) { - throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range); - } - + if (startFold && !startFold.range.isStart(startRow, startColumn)) + this.removeFold(startFold); + + if (endFold && !endFold.range.isEnd(endRow, endColumn)) + this.removeFold(endFold); + // Check if there are folds in the range we create the new fold for. var folds = this.getFoldsInRange(fold.range); if (folds.length > 0) {