From 4f58f8ab9f1aebea2b498943181234f30fdca2e6 Mon Sep 17 00:00:00 2001 From: Gayan Perera Date: Sat, 22 Oct 2022 11:31:19 +0200 Subject: [PATCH] Improve lambda breakpoint toggle (#146) When not selecting the whole lambda expression, the codeSelect fails to find the lambda method element. So instead of using the document selection, we use the breakpoint locator location if that provides more wider range. Signed-off-by: Gayan Perera --- .../jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java index 8098a9f7bf..e7b98218f6 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java @@ -338,7 +338,8 @@ static IStatus doToggleLambdaMethodBreakpoints(IWorkbenchPart part, ISelection s synchronized (unit) { unit.reconcile(ICompilationUnit.NO_AST, false, null, null); } - IJavaElement[] elements = unit.codeSelect(textSelection.getOffset(), textSelection.getLength()); + IJavaElement[] elements = unit.codeSelect(Math.min(textSelection.getOffset(), loc.getMemberOffset()), Math.max(textSelection.getLength(), loc.getNodeLength())); + if (elements == null || elements.length == 0) { ValidBreakpointLocationLocator locNew = new ValidBreakpointLocationLocator(loc.getCompilationUnit(), textSelection.getStartLine() + 1, true, true);