Skip to content

fix(ui): ensure text wrap works in HunkDiff #9120

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nshcr
Copy link

@nshcr nshcr commented Jun 21, 2025

The Appearance -> Text wrap option in Global Settings doesn't seem to have any effect.
I found that the issue was caused by the white-space: pre style, which was preventing text from wrapping.

So I changed white-space to pre-wrap when wrapText is true. It should be working correctly now.

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space

@Copilot Copilot AI review requested due to automatic review settings June 21, 2025 12:39
Copy link

vercel bot commented Jun 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 21, 2025 0:41am

Copy link

vercel bot commented Jun 21, 2025

@nshcr is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables text wrapping in the HunkDiff component by replacing the fixed white-space: pre with a dynamic pre-wrap when wrapText is enabled.

  • Updated the inline style on the <td> to set a --pre-wrap CSS variable based on wrapText.
  • Changed two hardcoded white-space: pre declarations to white-space: var(--pre-wrap).
Comments suppressed due to low confidence (2)

packages/ui/src/lib/hunkDiff/HunkDiffRow.svelte:213

  • [nitpick] The CSS variable name --pre-wrap could be confusing since it doesn’t clearly indicate it maps to the white-space property. Consider renaming it to something like --whitespace-value or --white-space-setting.
		style="--tab-size: {tabSize}; --wrap: {wrapText ? 'wrap' : 'nowrap'}; --pre-wrap: {wrapText

packages/ui/src/lib/hunkDiff/HunkDiffRow.svelte:298

  • We haven’t added any unit or visual tests to verify that wrapText actually causes wrapping. Consider adding a Jest/Playwright test or snapshot to cover this new behavior.
		white-space: var(--pre-wrap);

@@ -303,7 +305,7 @@
position: relative;
min-height: 18px;
text-wrap: var(--wrap);
white-space: pre;
white-space: var(--pre-wrap);
Copy link
Preview

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

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

The white-space: var(--pre-wrap) declaration is duplicated in two selectors. To improve maintainability, consider extracting it into a shared class or mixin to avoid repetition.

Copilot uses AI. Check for mistakes.

@Byron
Copy link
Collaborator

Byron commented Jun 22, 2025

Thanks a lot for contributing!

Do you have before-after screenshots by any chance?

Besides that, someone with better Csskills will take a look soon :)!

@nshcr
Copy link
Author

nshcr commented Jun 22, 2025

Kapture.2025-06-22.at.14.38.43.webm

@Byron Of course! I recorded a video showing the difference before and after applying this commit. The dev build was run based on the latest commit on master.

By the way, this issue likely exists in the v2 version of the component as well. Since I noticed that it has already been deprecated, I didn't make any changes there.
Let me know if I missed anything, I'd be happy to continue improving this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants