Skip to content

Commit

Permalink
Improve lambda breakpoint toggle (#146)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gayanper authored and SarikaSinha committed Oct 24, 2022
1 parent 11fb0a6 commit 4f58f8a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4f58f8a

Please sign in to comment.