Skip to content

Conversation

@HaudinFlorence
Copy link
Contributor

@HaudinFlorence HaudinFlorence commented Sep 25, 2025

When clicking on an empty line of code, a breakpoint is added to the first non empty previous line. In case there is already a breakpoint at this line, a second breakpoint was temporarily added in a second gutter line, in the time lapse of the click. To get rid of this behavior and in order to not remove the already present breakpoint, a modification of the _onGutterClick method was proposed.

Previously
Screencast From 2025-09-25 08-57-52.webm

With the solution of this PR (kernel blinking indicates the clicks on the gutter without any addition of a second breakpoint)
Screencast From 2025-09-25 08-59-32.webm

References

Should fix issue #17903

Code changes

Update the _onGutterClick method from EditorHandler class.
Introduce a private _getEffectiveClickedLine method that:

  • finds the first previous non empty line (the effective clicked line) if the initially clicked line is empty and return isLineEmpty set to true
  • returns directly the clicked line if the line is non empty and a isLineEmpty set to false

In the __onGutterClick, when clicking at the effective clicked position:

  • if there is no breakpoint, always add one
  • if there is already a breakpoint at the effective clicked position:
    - remove it if the line is not empty
    - make the already present breakpoint the selected to inform the user of what happens if the initially clicked position is not empty

User-facing changes

Backwards-incompatible changes

…e the case of trying to add a breakpoint on an empty line of code.
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@krassowski
Copy link
Member

Maybe if we are redirecting to a different line which already has a breakpoint that breakpoint should become selected to give user a feedback on what just happened?

targetLine.number
)
);
}
Copy link
Member

@JohanMabille JohanMabille Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is more or less a duplicate from this one.

I think it can be avoided by first handling the case clickedLine.text.trim() == '' to compute the new position, and then pass it to the part that updates the breakpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @JohanMabille. The comment has been taken into account in the following commit.

…od and update _onGutterClick method accordingly.
@krassowski krassowski added this to the 4.5.0 milestone Sep 25, 2025
@HaudinFlorence HaudinFlorence changed the title Debugger: fix behavior when trying to add a breakpoint on an empty line of code with the first previous non empty line already has a breakpoint Debugger: fix adding a breakpoint on an empty line of code and reclicking after addition Sep 25, 2025
@HaudinFlorence
Copy link
Contributor Author

HaudinFlorence commented Sep 25, 2025

Maybe if we are redirecting to a different line which already has a breakpoint that breakpoint should become selected to give user a feedback on what just happened?

@krassowski Thanks for your suggestion. I missed your comment. I will try to implement this now.

Copy link
Member

@JohanMabille JohanMabille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current changes look good to me.

@HaudinFlorence
Copy link
Contributor Author

Maybe if we are redirecting to a different line which already has a breakpoint that breakpoint should become selected to give user a feedback on what just happened?

This is new behavior, taking your comment into account @krassowski
Screencast From 2025-09-26 12-49-51.webm

@martinRenou
Copy link
Member

Maybe if we are redirecting to a different line which already has a breakpoint that breakpoint should become selected to give user a feedback on what just happened?

This is new behavior, taking your comment into account @krassowski Screencast From 2025-09-26 12-49-51.webm

Looks great!!

…int assignment when removing the selected breakpoint.
@HaudinFlorence
Copy link
Contributor Author

I just make a slight change, in order to not have the selected breakpoint becoming red when clicking for its removal
Screencast From 2025-09-26 13-02-26.webm

@HaudinFlorence
Copy link
Contributor Author

UI tests are failing but it doesn't seem related to this PR.

@krassowski
Copy link
Member

UI tests are failing but it doesn't seem related to this PR.

Most likely unrelated but we would want a green status before merging - if you could review #17928 that would help to fix it!

}
}
} else {
(isLineEmpty = false), (targetLine = clickedLine);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather unusual style. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is not intentional. Will change it to a more usual style.

@krassowski
Copy link
Member

Notice:   1 failed
    [jupyterlab] › test/jupyterlab/notebook-mermaid-diagrams.test.ts:107:11 › Notebook Mermaid Diagrams dark › Mermaid Diagram 18 architecture in dark theme 

This would be unrelated.

@HaudinFlorence HaudinFlorence force-pushed the fix_breakpoint_on_empty_line_behavior branch from 0a1d300 to 5caa757 Compare September 26, 2025 14:52
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @HaudinFlorence!

@krassowski krassowski merged commit 1945b54 into jupyterlab:main Sep 26, 2025
83 checks passed
@HaudinFlorence
Copy link
Contributor Author

Thank you @HaudinFlorence!

Thank you for the review and for the help @krassowski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants