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

ia doesn't handle nested braces when arguments are put each on it's own line #273

Open
nikitabobko opened this issue Jan 18, 2022 · 4 comments

Comments

@nikitabobko
Copy link

foo(
    arg1,
    bar(),
    arg3
)

Put the cursor on bar and type vIa
Expected:

foo(
    arg1,
    <selection>bar()</selection>,
    arg3
)

Actual: nothing is selected

@nikitabobko
Copy link
Author

Just an observation that such an example works as expected if you put the cursor on arg2, but if you put it on bar then it doesn't work

foo(
    arg1,
    arg2
        .bar(),
    arg3
)

@wellle
Copy link
Owner

wellle commented Jan 19, 2022

That's because it's working on the empty argument inside of bar(<here>). But Vim doesn't allow you to select an empty selection (unfortunately). For example try cIa and it should put your cursor inside of that argument. To work on the whole outer argument bar() try v2Ia. ✌️

@nikitabobko
Copy link
Author

Thanks for the explanation. I would say that this behavior is misleading and I would rather prefer the one I suggested. But even if we assume that the current one is the correct behavior then the behavior is inconsistent. In case of one line call: foo(arg1, bar(baz), arg) via it selects bar(baz). But in multiline case:

foo(
  arg1,
  bar(baz),
  arg3
)

it selects baz

@Hubro
Copy link

Hubro commented Mar 23, 2022

The issue seems to be that the argument text object prioritizes to seek over using the current cursor position, but only if the argument list is spread over multiple lines. This is definitely inconsistent with other text objects.

If you compare it to the pairs text object:

foo(
    bar(
        zod
    )
)

If your cursor is on the "b" in "bar" and you press vi) it will select:

foo(
<selection>
    bar(
        zod
    )
</selection>
)

If the pairs text object acted like the argument text object here, it would instead select:

foo(
    bar(
<selection>
        zod
</selection>
    )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants