I found joining lines is very slow only when folding mode is set to other than 'none'. Reproduction recipe: (WARNING: This will cause vary long hang up.) - Open doc/CHANGES.txt in jEdit source tree. - Do [Expand All Folds] (C+e x). (without this, another bug happens.) - Do [Select All] (C+a). - Try [Join Lines] (C+j). This patch will speed up this situation by minimizing calls to buffer.getFoldLevel(). Also, this patch will expand the care about black hole bug to support ... - multi line edit including folded line - more folding modes other than 'explicit' - modification at the middle of folded range. I want approval from Matthieu who made the current fixes for the bugs.