Skip to content

Improved support for NeoVintageous jump to next/prev change #458

Closed
@gerardroche

Description

@gerardroche

It would be great if the git_gutter_next_change and git_gutter_prev_change commands accepted a count and wrap options. A count meaning jump to the nth change, and wrap a boolean that enables and disables wrapping of results i.e. git_gutter_next_prev_change_wrap.

Ultimately the new API would allow (where count defaults to 1 and wrap defaults to whatever the global setting git_gutter_next_prev_change_wrap is.

self.view.run_command('git_gutter_next_change', {'count': 1, 'wrap': False})
self.view.run_command('git_gutter_prev_change', {'count': 3, 'wrap': False})

Reason

NeoVintageous provides GitGutter support for jumping forward and backwards through changes.

From the NeoVintageous documentation:

Command Description Documentation Dependencies Notes
[c Jump backwards to the previous start of a change. diff [Git Gutter] Disable wrapping: set git_gutter_next_prev_change_wrap to false (Preferences > Settings)
]c Jump forwards to the next start of a change. diff [Git Gutter] Disable wrapping: set git_gutter_next_prev_change_wrap to false (Preferences > Settings)

The commands allow you to jump to the next or prev change with ]c and [c.

The relevant code looks like this:

# https://neovim.io/doc/user/diff.html#[c
class _vi_left_square_bracket_c(ViMotionCommand):
    def run(self, mode=None, count=1):
        for i in range(count):
            self.view.run_command('git_gutter_prev_change')

# ...

# https://neovim.io/doc/user/diff.html#]c
class _vi_right_square_bracket_c(ViMotionCommand):
    def run(self, mode=None, count=1):
        for i in range(count):
            self.view.run_command('git_gutter_next_change')

The counts work by prefixing the commands with a number e.g. 3]c jumps to the 3rd change from the cursor.

An issue when using counts is that wrapping the results is confusing e.g. imagine your at the 3rd last change and you hit 4]c, if it wraps you don't know where you are in the document. Ideally you want it to stop at the end and display a status message.

You can disable wrapping via git_gutter_next_prev_change_wrap, but that's a global setting and the user may not want to disable that globally. So optional wrap argument to the commands would be useful.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions