Giter Club home page Giter Club logo

Comments (10)

The-Compiler avatar The-Compiler commented on August 24, 2024 1

But let's open another issue to track it.

Alright - let's continue that part in #39!

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

I didn't think user can type faster than the rendering of the QuickPick 😅. This actually was on my mind when deciding different solutions for implementing the shortcut , for major mode.

Anyway, I will implement a solution/fix that won't have this race condition for shortcut to major mode.

from vscode-which-key.

The-Compiler avatar The-Compiler commented on August 24, 2024

Hehe 😊 I guess when already having the keybinding memorized, and when it happens to be on two separate fingers, that doesn't hold true anymore 😄

Thanks for taking a look, let me know if I can help somehow!

from vscode-which-key.

The-Compiler avatar The-Compiler commented on August 24, 2024

Let me note that this seems like an issue in generic too - not sure if it's fixable though, and if so, whether I should open a separate issue for it.

If I hit SPC p f quickly, I can see pf being entered into the first QuickPick (before the second one gets displayed), then I end up in the +Project menu rather than the +Find file in project one.

edit: I can see there's some handling for this kind of case here:

private async onDidChangeValue(value: string, when?: string) {
this.when = when;
if (this.timeoutId) {
// When the menu is in the delay display mode
if (value.startsWith(this.enteredValue)) {
// Normal case where user enters key while in delay
value = value.substring(this.enteredValue.length);
} else if (this.enteredValue.startsWith(value)) {
// Disallow user from removing entered value when in delay
await this.setValue(this.enteredValue);
return;
} else {
// special case for fixing the quick pick value if trigger key command
// was called before the menu is displayed. When the menu is displayed,
// quick pick value is then selected. Any subsequent key will remove
// the value in the input.
await this.setValue(this.enteredValue + value);
}
}

and indeed it gets much better when I set whichkey.delay to 1 instead of 0. Maybe that logic should be active in some way even without a delay. I can try contributing a fix, but it might take me a while as I have a lot on my plate with my own projects 🙂

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

To solving the race condition of entering second key right after ,, I am thinking to supply initial value instead of simulating a key press after waiting the menu to open. The race condition for the original issue is that the simulated press comes after the key x.


If I hit SPC p f quickly, I can see pf being entered into the first QuickPick (before the second one gets displayed), then I end up in the +Project menu rather than the +Find file in project one.

For this case, it can be adjacent to original issue. But let's open another issue to track it. I think the cause of this is probably because multiple onDidChangeValue events are called before the pervious one has a chance to complete, and the time to finish onDidChangeValue probably also increased by #34. Two attempts in my heads are

  1. Have a queue to batch the onDidChangeValue to handle event in sequence. However, probably won't work by itself for the upcoming 1.57 (#34) due to how we modify the input.
  2. Change the input handling completely to eliminate modification of the input field.

indeed it gets much better when I set whichkey.delay to 1 instead of 0. Maybe that logic should be active in some way even without a delay

The difference is that

const updateQuickPick = async () => {
this.quickPick.busy = false;
this.enteredValue = '';
await this.setValue('');
this.quickPick.title = this.title;
this.quickPick.items = this.items;
};
is running on asynchronously when delay is 1. The might be due to us needing to have a workaround to await for set value for #34.

@The-Compiler Wondering what's the version of vscode you are running? Can you also try which-key version v0.8.4 to see if it's any better? Btw, I am also having trouble reproducing the issue on my computer

from vscode-which-key.

The-Compiler avatar The-Compiler commented on August 24, 2024

FWIW I can still reproduce this one even after downgrading to v0.8.4, using sleep 2 && xdotool type ',x'.

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

Thanks for checking in :) This in some sense is easier to fix than #39. We just need to build a proper support to pass in initial keys instead of "simulating" keys pressed with consecutively commands.

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

On a second thought, this might be solved with approach outlined in #39 with better input handling (queue).

from vscode-which-key.

stevenguh avatar stevenguh commented on August 24, 2024

Released in v0.10.0. The new implementation should be faster and more robust as it uses a processing queue to handle input change.

It is tested with

sleep 1; xdotool type ,; sleep 0.01; xdotool type x;
# or
sleep 1; xdotool type " "; sleep 0.01; xdotool type mx;

We have to wait for at least 10ms for the UI input to be shown before we can type. That's the limit of what we can do.

from vscode-which-key.

The-Compiler avatar The-Compiler commented on August 24, 2024

Seems to work beautifully now, at least from what I can see so far. Thanks! 👍

from vscode-which-key.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.