broot icon indicating copy to clipboard operation
broot copied to clipboard

Windows 11 in Modal mode - cannot get verb invocation with : (single colon)

Open tangent360 opened this issue 11 months ago • 2 comments

I'm using modal mode on Windows11 (broot v1.44.6) and I can't get verb invocation using : I have to use space to get out of command mode and start typing a verb. On MacOS and Linux it works with :  On Windows, in addition to space, typing / also works to switch out of command mode and begin a search. I confirmed the behavior is the same on an old version (v1.28.0) with fresh configs. I have the same issue if I launch it from cmd or powershell in Windows Terminal and from MSYS2 + fish in WezTerm. Anyone else using modal mode on windows that can confrirm : is not working?

tangent360 avatar Feb 02 '25 08:02 tangent360

I don't know any Rust - just installed the compiler today. But here is the issue:

The key bindings for the verb mode_input are set on startup in the VerbStore::add_builtin_verbs() (file: verb_store.rs)

        self.add_internal(mode_input)
            .with_key(key!(' '))
            .with_key(key!(':'))
            .with_key(key!('/'));

When you press : in Broot running on Windows it does nothing because it's not matching any known verb when it runs through the loop in PanelInput::find_key_verb() (file: panel_input.rs). When : is pressed, the second conditional inside the for loop always triggers on if !verb.keys.contains(&key) and the loop runs through all the verbs without finding a match.
It exits without taking any action and switching into input mode as desired. It fails to match because the : keypress is coming through as shift-:

I thought a quick workaround would be to modify the key binding in the VerbStore to put the existing definitions in a #[cfg(unix)] block and include a #[cfg(windows)] block with the following:

        self.add_internal(mode_input)
            .with_key(key!(' '))
            .with_key(key!(shift-':'))
            .with_key(key!('/'));

That gets you into input mode but it messes up the input buffer by removing the : so to type the verb to quit :q you have to type the : twice ... ::q. Maybe someone more familiar with the code can take a look at the necessary fix.

tangent360 avatar Feb 04 '25 23:02 tangent360

With the modifications above, if I modify PanelInput::enter_input_mode_with_key() to stick a : back on to the input_field then I think it works ... feels bit hacky though:

        if key == key!(shift - ':') {
            self.input_field.put_char(':');
        }

Would macOS or Linux ever come across a shift-: ?

tangent360 avatar Feb 05 '25 00:02 tangent360