Skip to content

Buffer view relocate should be improved #1790

@dmaluka

Description

@dmaluka

Description of the problem or steps to reproduce

When cursor is moved to a location which is far away (e.g. after a search, a goto line, or when opening a file at a given line), the view is always relocated in such a way that the cursor is at the bottom or at the top (minus scrollmargin), i.e. as if we just scrolled to this location. It is not like in other editors, and IMHO it is annoying. When we jump to a new location far away, we usually want to see more of its context, so the cursor should be placed closer to the center of the view, not near its edges. Certainly not near the bottom.

I suggest doing it similarly to other editors:

  • If the distance between the new and the old location is less than one frame (i.e. the view either doesn't change or is just "shifted") then the current behavior is ok.
  • Otherwise the current line should be at the center (like in vim, emacs and nano) or e.g. at 25% of the window height (like in gedit and geany). I'd personally opt for 25% of the height. Or it can be made configurable.

Specifications

Commit hash: 2b1ebd5
OS: any
Terminal: any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions