zed icon indicating copy to clipboard operation
zed copied to clipboard

LSP-server slow autocomplete response `jj` conflict

Open d1y opened this issue 1 year ago β€’ 2 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

My custom keymap

  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      "j j": "vim::NormalBefore"
    }
  }

When the return is slow, triggering jj will conflict and will be directly input into the buffer. (like jjkjkjjkkjxdfjk)

Slow? https://github.com/zed-industries/zed/issues/5166#issuecomment-2075801373

/cc @mrnugget @ConradIrwin

https://github.com/zed-industries/zed/assets/45585937/ed1068cf-75a3-4f17-aa21-d9c4e9f816bc


The VScode faster πŸ‘€, and no incorrect inference prompts in {}

https://github.com/zed-industries/zed/assets/45585937/ea3b53a2-25e6-4973-a29e-b199246de854

Environment

Zed: v0.133.2 (Zed Preview) OS: macOS 14.4.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

d1y avatar Apr 25 '24 19:04 d1y

I don't know if I expressed myself clearly

<script setup lang="ts">
import { ref, reactive } from 'vue'
const value = re
//              ^ <-- Cursor is here
//              ^ <-- Assuming that waiting for the lsp to return is too slow here and I want to enter it manually
//              ^ <-- Trigger (jj)`jjkjjaxv` enter insert mode it won't work
</script>

d1y avatar Apr 25 '24 19:04 d1y

Thanks for the report, makes sense, and I will see if I can reproduce.

ConradIrwin avatar Apr 26 '24 03:04 ConradIrwin

@d1y I heard that this might be resolved.

I think the likely problem (before) #12630 was that when the completion request returned we would change the keymap context; and when we change the context that invalidates any multi-key bindings.

I'm going to close this, but please re-open if you can still reproduce.

I am not sure why "j j": ["vim::SwitchMode", "Normal"] would have stopped working. If I have that in my key bindings it still seems to work. Do you have anything else going on that might cause problems?

ConradIrwin avatar Jun 06 '24 21:06 ConradIrwin

When I input quickly, there is still a problem. GIF:

fxxx

const x = falsejjkj
         // Fast input `false` and `j j` And `k` 
         // There will be this problem

Compared to VScode is silky and smooth πŸ€”

https://github.com/zed-industries/zed/assets/45585937/da3eecae-ffb8-42e3-8031-3da86f6178aa


πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ‘‡πŸ»The following questions can actually be deleted! Solving the binding of menu πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ‘‡πŸ»

{
    "context": "Editor && vim_mode == insert",
    "bindings": {
      "j j": "vim::NormalBefore"
    }
}

~~I want to re-open this question because I still have issues when using it in real life I provide a repo for reproducing the problem: https://github.com/sb-child/lsp~~

[
  {
    "context": "Editor && vim_mode == insert && !menu",
    "bindings": {
      "j j": "vim::NormalBefore"
    }
  }
]

https://github.com/zed-industries/zed/assets/45585937/cd47c2d1-231e-4fb6-bb15-df869b759415

I use zed-nightly

Zed: v0.140.0 (Zed Nightly e829a8c3b0564bc902cc0d0a530099be7f0f036e) OS: macOS 14.5.0 Memory: 16 GiB Architecture: aarch64

d1y avatar Jun 10 '24 12:06 d1y

Hi @ConradIrwin If #14942 fixes this issue, I just want to report: After using zed night, I found that there are still problems when I quickly input 'jjk'

https://github.com/user-attachments/assets/dc9d61b7-4930-4e9a-9210-d226ec904a3c

d1y avatar Jul 22 '24 19:07 d1y

@d1y I am struggling to reproduce this after #14942.

Trying to look at this video, I am also a bit confused. It seems like your keyboard overlay is missing some keystrokes. Can you please let me know what you typed exactly to get flajgjk to show up?

For me on Zed Preview, I can reproduce a problem starting from: Screenshot 2024-07-22 at 15 53 09

I then type o f j j as fast as possible. If I manage to get the first j before the autocomplete shows up then I can reproduce this bug.

On Zed Nightly, I cannot reproduce the bug with this technique.

ConradIrwin avatar Jul 22 '24 21:07 ConradIrwin

@ConradIrwin I'm sorry for bothering you I think you're right! I have used all three editors and found that the behavior is consistent

I think I just accidentally touched my fingernails because they have grown too long, so I have trimmed them now 🀑

https://github.com/user-attachments/assets/9a245efb-4cda-43d0-bcd6-c55081e2f3be

d1y avatar Jul 22 '24 22:07 d1y