Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim: yaf in typescript is not the same as vafy for arrow functions #24264

Open
thomasheartman opened this issue Feb 5, 2025 · 1 comment
Open
Labels

Comments

@thomasheartman
Copy link

Summary

Using yaf (or daf) inside an arrow function doesn't include the function declaration (const x = ). However, vafy/vafd does.

Steps to trigger the problem:

  1. Be in typescript mode
  2. Define an arrow function:
const f = (x: unknown) => {
  return x
}

const g = () => (x: unknown) => {
  return x
}
  1. Place cursor inside function body.
  2. yaf

Actual Behavior:
yaf only yanks from the last set of arguments. Both examples above yield the following when yanked from inside the braces:

(x: unknown) => {
    return x
}

Expected Behavior:
Similarly to vaf, the entire function (including the definition etc) is used. In other words, I'd expect them to yield

const f = (x: unknown) => {
    return x
}

and

const g = () => (x: unknown) => {
    return x
}

respectively.

Maybe related, vaf also has a problem when called from the name/declaration of the function.

Using the same function f, typing vaf with the cursor somewhere in const f = yields a selection that only includes const f = (x: unknown) => {. I'd expect it to be the entire function, not just the first line.

Screenies:
vaf from the body:

Image

vaf from the declaration

Image

Zed Version and System Specs

Zed: v0.171.6 (Zed)
OS: macOS 14.6.1
Memory: 16 GiB
Architecture: aarch64

@ConradIrwin
Copy link
Member

I think the proximate cause here is that we target visual line mode for the selection. We should update yank to look for the target visual mode of the object to fix this.

@ConradIrwin ConradIrwin added the vim label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants