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

Skip rendering gutters when gutter width exceeds view width #7821

Merged
merged 2 commits into from
Aug 8, 2023

Conversation

ArchUsr64
Copy link
Contributor

Closes #7154
Setting gutters.line-numbers.min-width to a value higher than terminal_width * terminal_height led to index out of bounds.
My approach was to have the width of LineNumbers be capped at 90% of the viewport size. Everything works as expected until the threshold is reached, when min_width is set to default value.

2023-08-03.21-59-41.mp4

@pascalkuthe
Copy link
Member

pascalkuthe commented Aug 4, 2023

As I already mentioned in #7156 (comment) fixing this by just limiting the line number width is just a hack. You cos have a gutter with 20 spacers and a terminal width of 20 (the terminal width can even be 0).

So instead of just limiting this setting the right way to fix this is ti perform bounds check before deciding to even draw gutter elements

@ArchUsr64
Copy link
Contributor Author

As I already mentioned in #7156 (comment) fixing this by just limiting the line number width is just a hack. You cos have a gutter with 20 spacers and a terminal width of 20 (the terminal width can even be 0).

My apologies, I misunderstood as it just being an issue with line-number. The most recent commits address this issue by disabling gutter rendering if gutters overflow the width.

The video showcased has 47 spacer defined in the [editor.gutters] section of the config.

2023-08-04.16-35-57.mp4

is_focused,
&mut line_decorations,
);
let gutter_overflow = view.gutter_offset(doc) == 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right way to go about it or if gutter_offset should return an Option<u16> instead with None in case of overflow

@the-mikedavis the-mikedavis changed the title Fixes gutter overflow Skip rendering gutters when gutter width exceeds view width Aug 8, 2023
@the-mikedavis the-mikedavis merged commit c7e9e94 into helix-editor:master Aug 8, 2023
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor crashes when gutters.line-numbers.min-width is too large
3 participants