Skip to content

Commit 8bbde51

Browse files
fix
1 parent 7c12b71 commit 8bbde51

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

packages/cli/src/components/DiffSplitContentLine.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const InternalDiffSplitLine = ({
7676

7777
const row = Math.max(oldRow, newRow);
7878

79-
const contentWidth = columns / 2 - width - 3;
79+
const contentWidth = columns / 2 - width - 2;
8080

8181
const oldLineNumberBG = oldLineIsDelete
8282
? theme === "light"
@@ -113,7 +113,7 @@ const InternalDiffSplitLine = ({
113113
return (
114114
<Box data-line={lineNumber} data-state={hasDiff ? "diff" : "plain"} height={row} width={columns}>
115115
{hasOldLine ? (
116-
<Box width={halfColumns - 1} flexShrink={0}>
116+
<>
117117
<Box width={width + 2} flexShrink={0}>
118118
<Box width={1}>
119119
<Text backgroundColor={oldLineNumberBG} wrap="wrap">
@@ -145,16 +145,16 @@ const InternalDiffSplitLine = ({
145145
syntaxLine={oldSyntaxLine}
146146
enableHighlight={enableHighlight}
147147
/>
148-
</Box>
148+
</>
149149
) : (
150-
<Box width={halfColumns - 1}>
150+
<Box width={halfColumns}>
151151
<Text backgroundColor={emptyBG} wrap="wrap">
152152
{" ".padEnd(halfColumns * row)}
153153
</Text>
154154
</Box>
155155
)}
156156
{hasNewLine ? (
157-
<Box width={halfColumns - 1} flexShrink={0}>
157+
<>
158158
<Box width={width + 2} flexShrink={0}>
159159
<Box width={1}>
160160
<Text backgroundColor={newLineNumberBG} wrap="wrap">
@@ -186,9 +186,9 @@ const InternalDiffSplitLine = ({
186186
syntaxLine={newSyntaxLine}
187187
enableHighlight={enableHighlight}
188188
/>
189-
</Box>
189+
</>
190190
) : (
191-
<Box width={halfColumns - 1}>
191+
<Box width={halfColumns}>
192192
<Text backgroundColor={emptyBG} wrap="wrap">
193193
{" ".padEnd(halfColumns * row)}
194194
</Text>

packages/cli/src/components/DiffSplitHunkLine.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const DiffSplitHunkLineGitHub = ({
3030

3131
const hunkContentColor = theme === "light" ? diffHunkContentColor.light : diffHunkContentColor.dark;
3232

33-
const contentWidth = columns - width - 4;
33+
const contentWidth = columns - width - 2;
3434

3535
return (
36-
<Box data-line={`${lineNumber}-hunk`} data-state="hunk">
36+
<Box data-line={`${lineNumber}-hunk`} data-state="hunk" height={1}>
3737
<Box width={width + 2}>
3838
<Text backgroundColor={hunkLineNumberBG}>{" ".padEnd(width + 2)}</Text>
3939
</Box>
@@ -69,10 +69,10 @@ const DiffSplitHunkLineGitLab = ({
6969

7070
const hunkContentColor = theme === "light" ? diffHunkContentColor.light : diffHunkContentColor.dark;
7171

72-
const contentWidth = columns / 2 - width - 2 - 1;
72+
const contentWidth = columns / 2 - width - 2;
7373

7474
return (
75-
<Box data-line={`${lineNumber}-hunk`} data-state="hunk">
75+
<Box data-line={`${lineNumber}-hunk`} data-state="hunk" height={1}>
7676
<Box width={width + 2}>
7777
<Text backgroundColor={hunkLineNumberBG}>{" ".padEnd(width + 2)}</Text>
7878
</Box>

packages/cli/src/components/DiffUnifiedContentLine.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const DiffUnifiedOldLine = ({
2020
width,
2121
theme,
2222
height,
23+
columns,
2324
rawLine,
2425
diffLine,
2526
plainLine,
@@ -33,6 +34,7 @@ const DiffUnifiedOldLine = ({
3334
width: number;
3435
height: number;
3536
theme: "light" | "dark";
37+
columns: number;
3638
rawLine: string;
3739
lineNumber: number;
3840
plainLine?: File["plainFile"][number];
@@ -45,7 +47,7 @@ const DiffUnifiedOldLine = ({
4547
const color = theme === "light" ? diffPlainLineNumberColor.light : diffPlainLineNumberColor.dark;
4648
const bg = theme === "light" ? diffDelLineNumber.light : diffDelLineNumber.dark;
4749
return (
48-
<Box data-line={index} data-state="diff" height={height}>
50+
<Box data-line={index} data-state="diff" height={height} width={columns}>
4951
<Box width={width * 2 + 2} flexShrink={0}>
5052
<Box width={width} justifyContent="flex-end">
5153
<Text color={color} wrap="wrap" backgroundColor={bg} data-line-old-num={lineNumber}>
@@ -91,6 +93,7 @@ const DiffUnifiedNewLine = ({
9193
width,
9294
theme,
9395
height,
96+
columns,
9497
rawLine,
9598
diffLine,
9699
plainLine,
@@ -104,6 +107,7 @@ const DiffUnifiedNewLine = ({
104107
width: number;
105108
height: number;
106109
theme: "light" | "dark";
110+
columns: number;
107111
rawLine: string;
108112
lineNumber: number;
109113
plainLine?: File["plainFile"][number];
@@ -116,7 +120,7 @@ const DiffUnifiedNewLine = ({
116120
const color = theme === "light" ? diffPlainLineNumberColor.light : diffPlainLineNumberColor.dark;
117121
const bg = theme === "light" ? diffAddLineNumber.light : diffAddLineNumber.dark;
118122
return (
119-
<Box data-line={index} data-state="diff" height={height}>
123+
<Box data-line={index} data-state="diff" height={height} width={columns}>
120124
<Box width={width * 2 + 2} flexShrink={0}>
121125
<Box width={width}>
122126
<Text backgroundColor={bg} wrap="wrap">
@@ -201,14 +205,11 @@ const _DiffUnifiedLine = memo(
201205
? diffFile.getOldPlainLine(oldLinenumber)
202206
: undefined;
203207

204-
const contentWidth = columns - (width + 1) * 2 - 1;
208+
const contentWidth = columns - (width + 1) * 2;
205209

206210
let row = getCurrentLineRow({ content: rawLine, width: contentWidth });
207211

208-
row =
209-
diffLine?.changes?.hasLineChange && diffLine.changes.newLineSymbol === NewLineSymbol.NEWLINE
210-
? row + 1
211-
: row;
212+
row = diffLine?.changes?.hasLineChange && diffLine.changes.newLineSymbol === NewLineSymbol.NEWLINE ? row + 1 : row;
212213

213214
const color = hasDiff
214215
? theme === "light"
@@ -233,6 +234,7 @@ const _DiffUnifiedLine = memo(
233234
theme={theme}
234235
width={width}
235236
height={row}
237+
columns={columns}
236238
rawLine={rawLine}
237239
diffFile={diffFile}
238240
index={lineNumber}
@@ -250,6 +252,7 @@ const _DiffUnifiedLine = memo(
250252
theme={theme}
251253
width={width}
252254
height={row}
255+
columns={columns}
253256
rawLine={rawLine}
254257
index={lineNumber}
255258
diffLine={diffLine}

packages/cli/src/components/DiffUnifiedHunkLine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const InternalDiffUnifiedHunkLine = ({
2828

2929
const hunkContentColor = theme === "light" ? diffHunkContentColor.light : diffHunkContentColor.dark;
3030

31-
const contentWidth = columns - width * 2 - 2 - 1;
31+
const contentWidth = columns - width * 2 - 2;
3232

3333
return (
3434
<Box data-line={`${lineNumber}-hunk`} data-state="hunk" height={1}>

packages/cli/test/index.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ index 5b301628..15aac42f 100644
1313
1414
componentWillUnmount(): void {
1515
this.props.$$__instance__$$.onUnmounted.forEach((f) => f());
16-
- this.effect.stop();
1716
+ this.reactiveEffect.stop();
1817
}
1918
@@ -64,6 +63,6 @@ render(
6463
data: { hunks: [hunks], newFile: { fileLang: "tsx" } },
6564
diffViewTheme: "dark",
6665
diffViewHighlight: true,
67-
diffViewMode: DiffModeEnum.Unified
66+
diffViewMode: DiffModeEnum.SplitGitLab
6867
})
6968
);

0 commit comments

Comments
 (0)