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

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

Closed
dustdfg opened this issue Nov 29, 2023 · 7 comments · Fixed by #3069
Closed

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

dustdfg opened this issue Nov 29, 2023 · 7 comments · Fixed by #3069

Comments

@dustdfg
Copy link
Contributor

dustdfg commented Nov 29, 2023

Description of the problem or steps to reproduce

  1. Open two bufpanes in split mode
  2. Set ruler enabled for at least one of them
  3. Drag the divider line to the side

When width of the pane is smaller than it is ruler size it crashes. If the pane doesn't have the ruler everything works good

Specifications

Commit hash: v2.0.13 68d88b5
OS: Debian 12
Terminal: foot

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 29, 2023

Hm, strange. I can't reproduce this.
Do you receive a backtrace?
Can you please try a different terminal?

@dustdfg
Copy link
Contributor Author

dustdfg commented Nov 29, 2023

Ok. I just tried with gnome terminal with the same result. And I understood my mistake in describing the issue. Did you tried to move the divider line to both sides? It won't crash if you will try to hide the split pane without ruler even when another split pane has it

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 29, 2023

I'm at a Debian testing with gnome console (kgx), opened an empty micro, used vsplit to create the splits, both of them have the ruler enabled (by default due to settings.json) and moved the divider to the left and to the right.
The only issue I can currently see is, that in the moment the divider is on the top left position the starting character of the file name will be removed.
But I can't reproduce the crash right now. 🤔

@dustdfg
Copy link
Contributor Author

dustdfg commented Nov 29, 2023

When you said backtrace you meant this?

Micro encountered an error: runtime.errorString runtime error: makeslice: cap out of range
runtime/slice.go:33 (0x450305)
runtime/slice.go:33 (0x4502ed)
github.com/zyedidia/micro/v2/internal/display/bufwindow.go:605 (0x88d910)
github.com/zyedidia/micro/v2/internal/display/bufwindow.go:788 (0x8901dc)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:407 (0x8ecad4)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:394 (0x8ec212)
runtime/proc.go:250 (0x43af12)
runtime/asm_amd64.s:1594 (0x46a961)

I tried to understand where it is but it was just in front of me

@dustdfg
Copy link
Contributor Author

dustdfg commented Nov 29, 2023

Ok. I just tried to open with empty micro because didn't do it earlier. Opened empty micro, vsplit, but crash

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 29, 2023

Let me guess, you've softwrap and wordwrap active?
This tells me the code location of bufwindow.go:605 and after activating this my micro now crashes in the same situation.

@dustdfg
Copy link
Contributor Author

dustdfg commented Nov 29, 2023

Yeah they are active. You are right I just disabled them and they work

dmaluka added a commit to dmaluka/micro that referenced this issue Dec 3, 2023
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 zyedidia#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.
dmaluka added a commit to dmaluka/micro that referenced this issue Dec 3, 2023
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 zyedidia#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.
JoeKar pushed a commit that referenced this issue Mar 13, 2024
* Fix gutter overwriting other split pane

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 #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.

* Don't display line numbers if buffer width is 0 and softwrap is on

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.

* Fix buffer text overwriting scrollbar when window width is 1 char
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants