Skip to content

fix: prevent panic when preview.open is false#799

Merged
dlvhdr merged 1 commit intodlvhdr:mainfrom
sideshowbarker:fix/798-preview-open-false
Mar 7, 2026
Merged

fix: prevent panic when preview.open is false#799
dlvhdr merged 1 commit intodlvhdr:mainfrom
sideshowbarker:fix/798-preview-open-false

Conversation

@sideshowbarker
Copy link
Contributor

@sideshowbarker sideshowbarker commented Mar 7, 2026

Bug: dash panics with "strings: negative Repeat count" when the config has preview.open set to false.

Cause: When preview.open is false, DynamicPreviewWidth is 0 and GetSidebarContentWidth() returns a negative value (0 − BorderWidth). If syncSidebar() proceeds to render, that negative width propagates to strings.Repeat(), which panics on a negative count.

Fix: Clamp GetSidebarContentWidth() with max(0, ...) so callers never see a negative width (root cause), and add an early return in syncSidebar() when the sidebar is closed so it doesn't needlessly render with zero width (defense-in-depth). Fixes #798.

Bug: dash panics with “strings: negative Repeat count” when the config
has preview.open set to false.

Cause: When preview.open is false, DynamicPreviewWidth is 0 and
GetSidebarContentWidth() returns a negative value (0 − BorderWidth). If
syncSidebar() proceeds to render, this negative width propagates to
strings.Repeat(), which panics on a negative count.

Fix: Clamp GetSidebarContentWidth() with max(0, ...) so callers never
see a negative width (root cause), and add an early return in
syncSidebar() when the sidebar is closed so it doesn’t needlessly render
with zero width (defense-in-depth).

Fixes dlvhdr#798
@dlvhdr dlvhdr merged commit 78b9ca5 into dlvhdr:main Mar 7, 2026
3 checks passed
@sideshowbarker sideshowbarker deleted the fix/798-preview-open-false branch March 7, 2026 10:02
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.

Panic: "strings: negative Repeat count" when preview.open is false

2 participants