Skip to content

Commit 4bb6f3a

Browse files
gayanperakurtakov
authored andcommitted
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 <[email protected]>
1 parent ddf0a0a commit 4bb6f3a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ static IStatus doToggleLambdaMethodBreakpoints(IWorkbenchPart part, ISelection s
338338
synchronized (unit) {
339339
unit.reconcile(ICompilationUnit.NO_AST, false, null, null);
340340
}
341-
IJavaElement[] elements = unit.codeSelect(textSelection.getOffset(), textSelection.getLength());
341+
IJavaElement[] elements = unit.codeSelect(Math.min(textSelection.getOffset(), loc.getMemberOffset()), Math.max(textSelection.getLength(), loc.getNodeLength()));
342+
342343
if (elements == null || elements.length == 0) {
343344
ValidBreakpointLocationLocator locNew = new ValidBreakpointLocationLocator(loc.getCompilationUnit(), textSelection.getStartLine()
344345
+ 1, true, true);

0 commit comments

Comments
 (0)