eclipse-theia/theia

Key F5 is assigned to 'run' and 'continue' simultaneously

Opened this issue · 4 comments

Bug Description:

The key F5 is assigned to 'run' and 'continue' by default. This leads to problems when it muss be decided which command should be applied.

Steps to Reproduce:

Take this python script:

a = 1
b = 2
c = 3
print('end')
  1. Make a breakpoint at line 3
  2. Press and hold F5
  3. Observe there are many debug sessions

press_and_hold_f5

Additional Information

  • Operating System: Windows 11
  • Theia Version: 1.56.2
msujew commented

Looks like we're missing a when context here to prevent the command from running if we're already in a debug session:

keybindings.registerKeybinding({
command: DebugCommands.START.id,
keybinding: 'f5'
});

VS Code is doing this similarly, see here.

Thank you @msujew for the fast response.
It seems there is no 'registerCommandAndKeybindingRule' in the Theia code.

I have a suggestion to change the Continue command:

registry.registerCommand(DebugCommands.CONTINUE, {
    execute: () => {
        if (this.manager.state === DebugState.Stopped) {
            // eslint-disable-next-line no-unused-expressions
            this.manager.currentThread && this.manager.currentThread.continue();
        }
    },
    // When there is a debug session, F5 should always be captured by this command
    isEnabled: () => this.manager.state !== DebugState.Inactive
});
msujew commented

It seems there is no 'registerCommandAndKeybindingRule' in the Theia code.

Well, they are two different services, so instead you would register commands and keybindings for those commands separately.

I have a suggestion to change the Continue command:

Note that the issue isn't so much that the CONTINUE command triggers, but rather that the START command triggers, even though a debugging session is already active.

Are you interested in contributing a pull request to this repo for the improvement?

Yes. I'm interested in contributing a pull request. I will open it in a couple of minutes...