zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.68k stars 2.07k forks source link

Vim motion "dt," (delete till comma) seems to badly misbehave? #13789

Open fasterthanlime opened 5 days ago

fasterthanlime commented 5 days ago

Check for existing issues

Describe the bug / provide steps to reproduce it

In the following Rust code:

use tokio::{fs::File, io::AsyncReadExt, runtime::Handle, sync::mpsc, time::Instant};
//                                    ☝️ cursor is here

...I would expect dt, to result in the following diff:

diff --git a/mods/media/src/lib.rs b/mods/media/src/lib.rs
index 3de9888..9e705c0 100644
--- a/mods/media/src/lib.rs
+++ b/mods/media/src/lib.rs
@@ -19,7 +19,7 @@ use std::{
     sync::Arc,
     time::Duration,
 };
-use tokio::{fs::File, io::AsyncReadExt, runtime::Handle, sync::mpsc, time::Instant};
+use tokio::{fs::File, io::AsyncReadExt, sync::mpsc, time::Instant};
 use tracing::{debug, error, info, warn};
 use xmltree::{Element, EmitterConfig, XMLNode};

Instead, it results in the following diff:

diff --git a/mods/media/src/lib.rs b/mods/media/src/lib.rs
index 3de9888..6a24dba 100644
--- a/mods/media/src/lib.rs
+++ b/mods/media/src/lib.rs
@@ -19,7 +19,7 @@ use std::{
     sync::Arc,
     time::Duration,
 };
-use tokio::{fs::File, io::AsyncReadExt, runtime::Handle, sync::mpsc, time::Instant};
+use tokio::{fs::File, io::AsyncR runtime::Handle, sync::mpsc, time::Instant};
 use tracing::{debug, error, info, warn};
 use xmltree::{Element, EmitterConfig, XMLNode};

(yes, it ended up deleting code before the cursor position).

In video form:

https://github.com/zed-industries/zed/assets/7998310/be04b948-ac76-4555-87db-ffd6c7dc35bf

Environment

Zed: v0.142.4 (Zed Preview) OS: macOS 15.0.0 Memory: 32 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

mrnugget commented 4 days ago

I cannot reproduce this:

https://github.com/zed-industries/zed/assets/1185253/49442d7e-226a-4f42-a3b2-ad9d7d6f6e6f

Two questions:

  1. Can you reproduce it with an empty keymap.json?
  2. What keyboard layout do you have?
fasterthanlime commented 13 hours ago

I can confirm that behavior seems to be caused by one of these in my keymap:

[
  {
    "context": "Editor && vim_mode == normal",
    "bindings": {
      "t w": "pane::CloseAllItems",
      "t k": "pane::ActivatePrevItem",
      "t j": "pane::ActivateNextItem",
    }
  }
]

With those commented out, dt behaves properly for me.

mrnugget commented 13 hours ago

Ah, that helps a lot! Thank you!