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

Make textobject select last paragraph #1992

Merged
merged 2 commits into from
Apr 13, 2022

Conversation

pickfire
Copy link
Contributor

@pickfire pickfire commented Apr 6, 2022

Last paragraph shoud be selected if the cursor was placed on the
whitespace paragraph part and map is done, otherwise it would do
nothing useful, but now we select backwards for the last paragraph
which behaves similarly to kakoune, making map useful for the last
paragraph with whitespace. Example usecase is to copy and paste last
ledger cli paragraph quickly by mapyp to duplicate last entry.

asciicast

I have always wanted to make it similar to kakoune for the last paragraph textobject behavior, did that in the last paragraph implementation but that have quite some bugs and I forgot to put it in the new one.

Last paragraph shoud be selected if the cursor was placed on the
whitespace paragraph part and `map` is done, otherwise it would do
nothing useful, but now we select backwards for the last paragraph
which behaves similarly to kakoune, making `map` useful for the last
paragraph with whitespace. Example usecase is to copy and paste last
ledger cli paragraph quickly by `mapyp` to duplicate last entry.
@archseer
Copy link
Member

Tagged for opinions, I don't usually use paragraph mappings.

@the-mikedavis
Copy link
Member

Trying this out locally, it works well but this case struck me as odd:

# Helix

#[|]#
[![Build status](https://github.com/helix-editor/helix/actions/workflows/build.yml/badge.svg)](https://github.com/helix-editor/helix/actions)

m-a-p there goes up to select # Helix instead of down to select the CI badge. Maybe it should always select forwards unless there are no more of the textobject left in the buffer. If we scan forward and hit EOF before the textobject, turn around and scan backwards instead?

Co-authored-by: Michael Davis <[email protected]>
@pickfire
Copy link
Contributor Author

pickfire commented Apr 12, 2022

m-a-p there goes up to select # Helix instead of down to select the CI badge. Maybe it should always select forwards unless there are no more of the textobject left in the buffer. If we scan forward and hit EOF before the textobject, turn around and scan backwards instead?

Thanks, that is definitely a bug. It should select the last paragraph. But it seemed like the issue is already there, just haven't fixed it. Looks like an issue with multiple newlines paragraph. But this could be merged then I work on that, seemed like two different issues, looking into that now.

@archseer archseer merged commit 62283fd into helix-editor:master Apr 13, 2022
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

Successfully merging this pull request may close these issues.

3 participants