Ashark
Ashark

Reputation: 843

Can I configure VS Code to disable Breakpoint by middle click?

I am switching from PyCharm to VS Codium. I want to be able to disable breakpoints by middle mouse click, like in pycharm.

Currently, I can disable a breakpoint by right click at breakpoint and select Disable Breakpoint:

enter image description here

Another way is to disable it in list in Breakpoints view.

But I want to be able to quickly enable/disable it by just clicking with mouse wheel (middle button). Is it possible to configure VS Code this way? Currently, when I middle click on breakpoint, this is ignored, and instead a text from selection clipboard is pasted (it is the default behavior in linux). Visual Studio Code version is 1.66.1.

Upvotes: 1

Views: 620

Answers (2)

Ashark
Ashark

Reputation: 843

I currently use the following workaround.

Remap the middle click to some button.

For wayland several utilities can be used for that. Let's take kbct.

Add such config (edit for your needs) /etc/kbct/config.yml:

- keyboards: [ "Logitech MX Master" ]

  keymap:
    btn_middle: f15

Then start kbct.service.

Create the ruler script

Make the file choose_press.sh:

#!/bin/bash

class=$(xdotool getactivewindow getwindowclassname)

if [ "x$class" == "xVSCodium" ]; then
    ydotool click 0xC1  # right click
    sleep 0.2
    ydotool key 107:1 107:0 28:1 28:0  # End, Enter
else
    ydotool click 0xC2  # middle click
fi

Do not forget to add executable permissions.

Bind shortcut to the script

To assign a command to shortcut in KDE, go to System Settings -> Shortcuts -> Custom Shortcuts, right click, choose New -> Global Shortcut -> Command/URL. Go to Action tab and fill in the command. In this case it will be the path to choose_press.sh. Note: do not use ~ there. And in Trigger tab assign the shortcut. In this case we use f15 (use some way to simulate it, if it is not presented on the keyboard).

Start VS Codium

Use vs codium in X11 mode. This is because I currently do not know how to get active window class in wayland.

Result

Now if you middle click in vscodium window, it will receive the sequence of input that leads to enabling/disabling breakpoint. In any other window, the middle click will behave as normal.


There is debug.enableOrDisableBreakpoint in codium, but toggling that with shortcut only works when the cursor is on the line with breakpoint. I did not found a way to move cursor to the line where you pressed (method to get the mouse over line?). So I made that complex thing with ydotool choose_press.sh.

I also tried to start stop kbct by window activation, but that is unfortunately broken in kde wayland currently.

Upvotes: 0

Alexander
Alexander

Reputation: 17345

There is no way at the moment to customize mouse click events. There are a few hardcoded options you can change in the settings, but it is extremely limited like pressing ctrl and the mouse wheel for zoom. As far as I am aware, disabling breakpoints is not among those options.

Check out: https://github.com/microsoft/vscode/issues/3130

Upvotes: 1

Related Questions