Skip to content

Fix ruler overwriting neighboring split pane + fix crash #3052#3069

Merged
JoeKar merged 3 commits intomicro-editor:masterfrom
dmaluka:resize-overwrite-fix
Mar 13, 2024
Merged

Fix ruler overwriting neighboring split pane + fix crash #3052#3069
JoeKar merged 3 commits intomicro-editor:masterfrom
dmaluka:resize-overwrite-fix

Conversation

@dmaluka
Copy link
Collaborator

@dmaluka dmaluka commented Dec 3, 2023

When we resize a split pane to a very small width, so that the ruler does not fit in the pane, it overwrites the sibling split pane.

To fix it, clean up the calculation of gutter width, buffer width and scrollbar width, so that they add up exactly to the window width, and ensure that we don't draw the gutter beyond this calculated gutter
width (gutterOffset).

As a bonus, this also fixes the crash #3052 (observed when resizing a split pane to a very small width, if wordwrap is enabled), by ensuring that bufWidth is never negative.

Fixes #3052

When we resize a split pane to a very small width, so that the gutter
does not fit in the pane, it overwrites the sibling split pane.

To fix it, clean up the calculation of gutter width, buffer width and
scrollbar width, so that they add up exactly to the window width, and
ensure that we don't draw the gutter beyond this calculated gutter
width (gutterOffset).

As a bonus, this also fixes the crash micro-editor#3052 (observed when resizing a
split pane to a very small width, if wordwrap is enabled), by ensuring
that bufWidth is never negative.

[*] By the gutter we mean of course gutter + diffgutter + ruler.
If softwrap is enabled, the line numbers displayed in the ruler depend
on the heights of the displayed softwrapped lines, which depend on the
width of the displayed buffer. If this width is 0 (e.g. after resizing
buffer pane to a very small width), there is no displayed text at all,
so line numbers don't make sense. So don't display line numbers in this
case.
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.

Crash when pane/(v)split widthe is smaller than ruler size

2 participants