Skip to content

Commit c9465f6

Browse files
nshcrPavelLaptev
andauthored
fix(ui): ensure text wrap works in HunkDiff (#9120)
* fix(ui): ensure text wrap works in HunkDiff * Add a long line to test the feature * remove redundant `text-wrap` it didn't work * rename "Text wrap" to "Soft wrap" "Soft wrap" more clearly indicates that this is visual wrapping (lines appear wrapped on screen) vs "hard wrap" (actually inserting line breaks), which is particularly important in a diff context where the actual content shouldn't be modified. Since this is specifically for diff/code viewing, "soft wrap" aligns better with developer expectations and terminology. * align numbers in count columns to the top instead of center --------- Co-authored-by: Pavel Laptev <[email protected]>
1 parent 1af9337 commit c9465f6

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

apps/desktop/src/components/projectSettings/AppearanceSettings.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
on:branchSelected={async (e) => {
2222
- selectedBranch = e.detail;
2323
- if ($platformName === 'win32') {
24-
+ if ($platformName === 'win64') {
24+
+ if ($platformName === 'win64' && $userSettings.enableAdvancedFeatures && project.hasRemoteOrigin) {
2525
setTarget();
2626
}
2727
}}`;
@@ -138,10 +138,10 @@
138138

139139
<SectionCard labelFor="wrapText" orientation="row" roundedTop={false} roundedBottom={false}>
140140
{#snippet title()}
141-
Text wrap
141+
Soft wrap
142142
{/snippet}
143143
{#snippet caption()}
144-
Wrap text in the diff view once it hits the end of the viewport.
144+
Soft wrap long lines in the diff view to fit within the viewport.
145145
{/snippet}
146146

147147
{#snippet actions()}

packages/ui/src/lib/components/InfoButton.svelte

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
title?: string;
1111
size?: 'small' | 'medium';
1212
maxWidth?: string;
13+
iconTopOffset?: string;
1314
icon?: keyof typeof iconsJson;
1415
inheritColor?: boolean;
1516
children: Snippet;
@@ -19,6 +20,7 @@
1920
title,
2021
size = 'medium',
2122
maxWidth = '16rem',
23+
iconTopOffset = '10%',
2224
icon,
2325
children,
2426
inheritColor
@@ -67,6 +69,8 @@
6769
role="tooltip"
6870
onmouseenter={handleMouseEnter}
6971
onmouseleave={handleMouseLeave}
72+
style:--icon-top-offset={iconTopOffset}
73+
style:--size={size === 'small' ? '12px' : '14px'}
7074
>
7175
{#if icon}
7276
<div class="info-custom-icon" class:inherit-color={inheritColor}>
@@ -104,12 +108,9 @@
104108

105109
<style lang="postcss">
106110
.wrapper {
107-
--default-size: 14px;
108-
--small-size: 12px;
109-
110111
display: inline-flex;
111112
position: relative;
112-
transform: translateY(10%);
113+
transform: translateY(var(--icon-top-offset));
113114
}
114115
115116
.info-custom-icon {
@@ -124,8 +125,9 @@
124125
125126
.info-button {
126127
position: relative;
127-
width: 50px;
128-
border-radius: var(--default-size);
128+
width: var(--size);
129+
height: var(--size);
130+
border-radius: var(--size);
129131
box-shadow: inset 0 0 0 1.5px var(--clr-text-2);
130132
color: var(--clr-text-2);
131133
transition: box-shadow var(--transition-fast);
@@ -152,38 +154,28 @@
152154
}
153155
154156
.wrapper.medium {
155-
& .info-button {
156-
width: var(--default-size);
157-
height: var(--default-size);
158-
159-
&::before {
160-
top: 3px;
161-
width: 2px;
162-
height: 2px;
163-
}
164-
&::after {
165-
top: 6px;
166-
width: 2px;
167-
height: 5px;
168-
}
157+
& .info-button::before {
158+
top: 3px;
159+
width: 2px;
160+
height: 2px;
161+
}
162+
& .info-button::after {
163+
top: 6px;
164+
width: 2px;
165+
height: 5px;
169166
}
170167
}
171168
172169
.wrapper.small {
173-
& .info-button {
174-
width: var(--small-size);
175-
height: var(--small-size);
176-
177-
&::before {
178-
top: 3px;
179-
width: 2px;
180-
height: 2px;
181-
}
182-
&::after {
183-
top: 6px;
184-
width: 2px;
185-
height: 3px;
186-
}
170+
& .info-button::before {
171+
top: 3px;
172+
width: 2px;
173+
height: 2px;
174+
}
175+
& .info-button::after {
176+
top: 6px;
177+
width: 2px;
178+
height: 3px;
187179
}
188180
}
189181

packages/ui/src/lib/components/hunkDiff/HunkDiffRow.svelte

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@
206206
class:locked
207207
class:staged
208208
>
209-
<InfoButton inheritColor size="small" icon="locked-extra-small" maxWidth="15rem">
209+
<InfoButton
210+
inheritColor
211+
size="small"
212+
icon="locked-extra-small"
213+
maxWidth="15rem"
214+
iconTopOffset="0"
215+
>
210216
{@render lockWarning(row.locks ?? [])}
211217
</InfoButton>
212218
</td>
@@ -226,7 +232,7 @@
226232

227233
<td
228234
class="table__textContent"
229-
style="--tab-size: {tabSize}; --wrap: {wrapText ? 'wrap' : 'nowrap'}"
235+
style="--tab-size: {tabSize}; --pre-wrap: {wrapText ? 'pre-wrap' : 'pre'}"
230236
class:readonly={true}
231237
data-no-drag
232238
class:diff-line-deletion={row.type === SectionType.RemovedLines}
@@ -308,8 +314,7 @@
308314
padding-left: 4px;
309315
font-size: 12px;
310316
line-height: 1.25;
311-
text-wrap: var(--wrap);
312-
white-space: pre;
317+
white-space: var(--pre-wrap);
313318
cursor: text;
314319
tab-size: var(--tab-size);
315320
user-select: text;
@@ -318,8 +323,7 @@
318323
.table__row-header {
319324
position: relative;
320325
min-height: 18px;
321-
text-wrap: var(--wrap);
322-
white-space: pre;
326+
white-space: var(--pre-wrap);
323327
cursor: text;
324328
}
325329
@@ -391,7 +395,9 @@
391395
background-color: var(--clr-diff-count-bg);
392396
color: var(--clr-diff-count-text);
393397
font-size: 11px;
398+
line-height: 1.5; /* Visually centered with 12px font size that diff lines have */
394399
text-align: right;
400+
vertical-align: top;
395401
touch-action: none;
396402
user-select: none;
397403
@@ -451,6 +457,8 @@
451457
border-right: 1px solid var(--clr-border-2);
452458
background-color: var(--clr-diff-count-bg);
453459
color: var(--clr-diff-count-text);
460+
line-height: 1;
461+
vertical-align: top;
454462
455463
&.diff-line-addition {
456464
border-color: var(--clr-diff-addition-count-border);

0 commit comments

Comments
 (0)