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

Implement new textobject for indentation level #9843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EpocSquadron
Copy link
Contributor

@EpocSquadron EpocSquadron commented Mar 10, 2024

Closes #1810.

Current Implementation

This implements a textobject corresponding to the current indentation level of the selection, bound on i. It is only implemented for the "match mode" (eg. mii or mai). It takes a count, where count extends the selection to further leftward indented surroundings than represented by the current selection. mai will skip over empty lines to extend the selection, whereas mii will stop on the first empty line above or below. Selection direction is preserved on extension.

I've added as many tests as I could keep straight in my head. I almost feel like some sort of property testing might be better able to find the edge cases, but what is implemented is what I had time to think through.

Future Direction

I could implement "next" (]i) and "prev" ([i) to be the next contiguous block of the same indentation level as the current selection, after one or more blank lines. However I don't want to hold this implementation back as it is now complete and I have little time to dedicate to further features. Others are welcome to implement, or I may return to it at a later date.

@the-mikedavis the-mikedavis added A-tree-sitter Area: Tree-sitter S-waiting-on-review Status: Awaiting review from a maintainer. labels Mar 11, 2024
@EpocSquadron
Copy link
Contributor Author

I've updated the original description to hopefully be more readable, included a screencast of the feature, and made clear the call for feedback on potentially extending the logic.

@EpocSquadron EpocSquadron force-pushed the implement-indent-level-textobject branch from 4ef159c to 054939d Compare March 12, 2024 23:07
@daedroza
Copy link
Contributor

Hey @EpocSquadron , this look like a great change, for next and prev implementation, only the contiguous block should matter. I would be waiting for that change if you're willing to implement, thanks again!

@EpocSquadron EpocSquadron force-pushed the implement-indent-level-textobject branch 2 times, most recently from 1d0afad to 5a746ce Compare July 10, 2024 03:59
@EpocSquadron
Copy link
Contributor Author

I've updated this branch, squashed the changes, addressed feedback, and updated the description of the PR to reflect the current state. I removed the short screen recording I had up prior as it no longer accurately reflected the functionality. I ran out of time to record a new one.

@daedroza I'm not able to dedicate time towards the next/prev motions at the moment. I may return at a later date but no promises or timeline. I did at least move forward with distinguishing the inside and around versions, so hopefully that is sufficient to get this merged and expand on later.

This implements a textobject corresponding to the current indentation
level of the selection(s). It is only implemented for "match mode"
bound to `i` and takes a count, where count extends the selection
leftwards additional indentation levels. Inside and Around versions are
distinguished by whether they tolerate empty lines.
@EpocSquadron EpocSquadron force-pushed the implement-indent-level-textobject branch from 5a746ce to e1247d6 Compare July 18, 2024 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add textobject for current indentation
4 participants