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
44.78k stars 2.42k forks source link

vim: Sometime `vap` select two paragraphs #13383

Open dangh opened 2 months ago

dangh commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

This is the test file https://github.com/reduxjs/redux/blob/005feda1aec5ccf1efd865f61822e3f599dae3e2/src/createStore.ts#L298

When I'm on line 298, in normal mode, type vap will select two paragraphs instead of one as in Vim. You can see the differences in the screenshot below.

I'm using Nightly build but it happen on both Preview and Stable builds.

Environment

Zed: v0.142.0 (Zed Nightly d3b3e072a7ef6a4b10de46afcb684dc64fec0d8d) OS: macOS 15.0.0 Memory: 32 GiB Architecture: aarch64

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

Screenshot 2024-06-22 at 15 17 02

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

Zed.log


seffradev commented 1 month ago

I noticed that this (at least to me) happens when I have the Inline Assist menu open, but specifically when vap selects lines beneath the line I open the menu on. E.g. if the I open Inline Assist on line 297 in the test file above and select paragraphs above that line, vap selects as expected, but when I do the same on lines beneath 297 it most often selects two paragraphs. Not always, but frequently.

I've also tried in a Rust project, not available online but an example snippet here.

use derive_more::Display;
use request::Request;
use response::{Response, Status};
use thiserror::Error;

pub mod address;
pub mod codec;
pub mod request;
pub mod response;

#[derive(Debug, Display, Error)]
pub enum Error {                      // open Inline Assist menu here
    Io(#[from] std::io::Error),
}

pub type Result<T> = std::result::Result<T, Error>;

pub struct Pdu {
    pub sequence_number: u32,
    pub command: Kind,
}

pub enum Kind {
    Request(Request),
    Response(Status, Response),
}

When I vap on the two paragraphs above my Inline Assist comment, only one paragraph is selected, but when I do it on the Error enum, it selects a total of three paragraphs, stopping at the end of the Pdu struct.

Hope this helps.

Environment

Zed: v0.142.6 (Zed Stable https://github.com/zed-industries/zed/commit/5d5ada9003804e49f3352439c2a911524c47a2ac) OS: macOS 14.4.1 (23E224) Memory: 16 GiB Architecture: aarch64