Skip to content

feature: make behavior when header.border = true consistent whether or not there is a blank newline above/below the header #183

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

Closed
hneutr opened this issue Sep 24, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@hneutr
Copy link

hneutr commented Sep 24, 2024

Is your feature request related to a problem? Please describe.

Currently, when header.border = true and there is a blank newline above the header, the border is applied to the blank newline, but when there is a non-blank line above the header, a "phantom" line is rendered and the border is applied to that "phantom" newline, and this behavior is the same for the border below the header.

This makes moving up or down by line when there is a header unpredictable. To make the situation a bit clearer:

The following would look the same:

text [cursor]

# header
text [cursor]
# header

However, moving the cursor down a line in the first example would move the cursor to the empty line (and hide the border of the header), while moving the cursor down in the second example would move the cursor to the line with the header.

Describe the solution you'd like

When header.border = true, render the border on a "phantom" line, regardless of whether or not there is an empty line above or below it.

This would have the added benefit of fixing the rendering headers at the top and bottom of the file (currently, when there is a header at the top of the file, the top border is not rendered, and the same is true of the bottom border for a header on the last line of the file).

Describe alternatives you've considered

Add a configuration value to control this behavior, eg: header.border_position, with (perhaps) a value of overlay preserving the current behavior, and a value of virtual (or some better-named value) triggering the consistent behavior I've described above.

Additional information

Again, I really appreciate this plugin and all of the work you've put into it! It's meaningfully improved my Neovim experience.

@hneutr hneutr added the enhancement New feature or request label Sep 24, 2024
@MeanderingProgrammer
Copy link
Owner

The top and bottom lines don't get fixed by rendering a virtual line on them.

Under the current implementation there's already a virtual line being rendered in both places: #123 (comment)

You can see the top one if you hit <C-b>.

@MeanderingProgrammer
Copy link
Owner

I can add an opt in to make the lines always virtual.

MeanderingProgrammer added a commit that referenced this issue Sep 24, 2024
## Details

Request 1: #182

This change adds support for 2 features.

The first is around the padding options for headings. For each of:

- `left_margin`
- `left_pad`
- `right_pad`
- `min_width`

We now accept an array of numbers in addition to a single number. When
the value is an array we index it using the level and we clamp the last
value. This is the same behavior we support for `width`.

Request 2: #183

This request is simply to allow using virtual lines for heading borders
all the time rather than trying to overlay borders on empty lines.

This can now be opted in to by setting `border_virtual` to `true`.
@MeanderingProgrammer
Copy link
Owner

Added this here: aad1a12.

You can opt into it by setting heading.border_virtual to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants