Skip to content

Vi mode: support % motion and ib/ab text objects#10593

Closed
nikitabobko wants to merge 4 commits into
fish-shell:masterfrom
nikitabobko:bobko/patch-1
Closed

Vi mode: support % motion and ib/ab text objects#10593
nikitabobko wants to merge 4 commits into
fish-shell:masterfrom
nikitabobko:bobko/patch-1

Conversation

@nikitabobko

@nikitabobko nikitabobko commented Jun 29, 2024

Copy link
Copy Markdown
Contributor

Description

I didn't add new tests, since I didn't find that fish has any existing tests for input functions.

It's my first time writing in Rust, so I might did some noob mistakes. I tried to stick with the existing code style as much as possible, but I might made mistakes.

I understand that I introduce a new API, which could be a reason to reject the PR.

The implementation is obviously not 100% the same as in VIM, but it should cover the major cases. The biggest missing part is real matching of "matching brackets", I just scan the text to find next the first occurence of the bracket, but I think it's good enough. (UPD: supported)

My commits don't cover ci(, ci{, ci[, and friends (The introduced jump-to-matching-bracket can't help here, because it would match any bracket). I think that if fish supported jump-to-matching-char (brackets match their respecitve brackets, regular chars match themselves), mentioned bindings could be added (by changing existing b,i binding). If you are ok with the proposal, I can implement it in the next PR

Makes progress in issue #1842

Thank you for checking the PR regardless of your decision! And thank for the great shell!

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed.
    It's not a regression. So I guess check?
  • User-visible changes noted in CHANGELOG.rst
  • I read CONTRIBUTING.rst

Part of fish-shell#1842

Split to:
- jump_and_remember_last_jump. What previously was called jump, now called
  jump_and_remember_last_jump
- jump. Only jump, don't remember last jump. Now it's also possible to pass
  vector of targets

The commit is pure refactoring, no functional changes are introduced.
The refactoring is needed for the next commits
Comment thread src/reader.rs Outdated
@nikitabobko nikitabobko force-pushed the bobko/patch-1 branch 2 times, most recently from 47c5271 to 117d1c5 Compare June 29, 2024 09:06
@nikitabobko

nikitabobko commented Jun 29, 2024

Copy link
Copy Markdown
Contributor Author

The biggest missing part is real matching of "matching brackets"

Actually, I think it's not that hard. I will implement real brackets matching

UPD: supported

@nikitabobko nikitabobko marked this pull request as draft June 29, 2024 09:48
Part of fish-shell#1842

It's like jump-to-matching-bracket, but jumps right before the bracket

I will use it to mimic vi 'ab' and 'ib' text objects in the next commit

Given complicated semantics of jump-till-matching-bracket, an alternative name
could be 'jump-inside-matching-brackets'. But that would make names non-symmetrical.
I'm not sure what is worse.
Part of fish-shell#1842

The implementation is obviously isn't 100% vi compatible, but works good enough
for major cases

This commit depends on previous commits where jump-{to, till}-matching-bracket
motions were introduces
@nikitabobko nikitabobko marked this pull request as ready for review June 29, 2024 11:06
@ridiculousfish ridiculousfish added this to the fish next-3.x milestone Jun 30, 2024
@ridiculousfish

Copy link
Copy Markdown
Member

Thank you!

@ridiculousfish

Copy link
Copy Markdown
Member

Merged as e03e5e1

@nikitabobko nikitabobko deleted the bobko/patch-1 branch July 1, 2024 11:42
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants