From b14ee042505d2a51af191d87a5a9c2f5b63c94c3 Mon Sep 17 00:00:00 2001 From: Jakub Suliga Date: Wed, 15 Jan 2025 10:10:41 +0100 Subject: [PATCH] Fix for bug #1539 --- .../DefaultJavaFoldingStructureProvider.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java index e212f37c39a..0f41c8c525f 100755 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/folding/DefaultJavaFoldingStructureProvider.java @@ -1279,23 +1279,15 @@ protected final IRegion alignRegion(IRegion region, FoldingStructureComputationC IDocument document= ctx.getDocument(); try { - int start= document.getLineOfOffset(region.getOffset()); - int end= document.getLineOfOffset(region.getOffset() + region.getLength()); + int end= document.getLineOfOffset(region.getOffset() + region.getLength() - 1); if (start >= end) return null; - - int offset= document.getLineOffset(start); - int endOffset; - if (document.getNumberOfLines() > end + 1) - endOffset= document.getLineOffset(end + 1); - else - endOffset= document.getLineOffset(end) + document.getLineLength(end); + int offset = document.getLineOffset(start); + int endOffset = document.getLineOffset(end); return new Region(offset, endOffset - offset); - } catch (BadLocationException x) { - // concurrent modification return null; } }