Skip to content

Commit 0ed9a41

Browse files
cli fix
1 parent b885453 commit 0ed9a41

File tree

4 files changed

+32
-62
lines changed

4 files changed

+32
-62
lines changed

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
},
6060
"devDependencies": {
6161
"@my-react/react": "^0.3.16",
62-
"@my-react/react-terminal": "^0.0.9",
62+
"@my-react/react-terminal": "^0.0.10",
6363
"@types/react": "^19.1.8"
6464
},
6565
"peerDependencies": {
6666
"react": "^19.1.0",
67-
"ink": "^6.0.1"
67+
"ink": "^6.1.0"
6868
}
6969
}

packages/cli/src/components/DiffContent.tsx

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -93,44 +93,31 @@ const DiffString = ({
9393
data-range-start={range.location}
9494
data-range-end={range.location + range.length}
9595
flexWrap="wrap"
96+
backgroundColor={bg}
9697
>
9798
{str1.split("").map((char, index) => (
98-
<Text key={index} backgroundColor={bg}>
99-
{char}
100-
</Text>
99+
<Text key={index}>{char}</Text>
101100
))}
102101
{str2.split("").map((char, index) => (
103102
<Text key={index} backgroundColor={highlightBG}>
104103
{char}
105104
</Text>
106105
))}
107106
{str3.split("").map((char, index) => (
108-
<Text key={index} backgroundColor={bg}>
109-
{char}
110-
</Text>
107+
<Text key={index}>{char}</Text>
111108
))}
112-
{""
113-
.padStart(height * width - rawLine.length)
114-
.split("")
115-
.map((char, index) => (
116-
<Text key={char + "-" + index} backgroundColor={bg}>
117-
{char}
118-
</Text>
119-
))}
120109
</Box>
121110
{isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (
122-
<Box width={width - 1}>
123-
<Text backgroundColor={bg} wrap="truncate">
124-
{"\\ No newline at end of file".padEnd(width)}
125-
</Text>
111+
<Box width={width - 1} backgroundColor={bg}>
112+
<Text wrap="truncate">{"\\ No newline at end of file".padEnd(width)}</Text>
126113
</Box>
127114
)}
128115
</>
129116
);
130117
}
131118

132119
return (
133-
<Box width={width - 1} flexWrap="wrap">
120+
<Box width={width - 1} flexWrap="wrap" backgroundColor={bg}>
134121
{rawLine
135122
.padEnd(width * height)
136123
.split("")
@@ -190,6 +177,7 @@ const DiffSyntax = ({
190177
data-range-start={range.location}
191178
data-range-end={range.location + range.length}
192179
flexWrap="wrap"
180+
backgroundColor={bg}
193181
>
194182
{syntaxLine.nodeList?.map(({ node, wrapper }, index) => {
195183
const lowlightStyles = getStyleFromClassName(wrapper?.properties?.className?.join(" ") || "");
@@ -200,7 +188,7 @@ const DiffSyntax = ({
200188
return (
201189
<React.Fragment key={index}>
202190
{node.value.split("").map((char, index) => (
203-
<Text key={index} backgroundColor={bg} {...lowlightStyle} {...shikiStyle}>
191+
<Text key={index} {...lowlightStyle} {...shikiStyle}>
204192
{char}
205193
</Text>
206194
))}
@@ -223,7 +211,7 @@ const DiffSyntax = ({
223211
return (
224212
<React.Fragment key={index}>
225213
{str1.split("").map((char, index) => (
226-
<Text key={index} backgroundColor={bg} {...lowlightStyle} {...shikiStyle}>
214+
<Text key={index} {...lowlightStyle} {...shikiStyle}>
227215
{char}
228216
</Text>
229217
))}
@@ -233,36 +221,26 @@ const DiffSyntax = ({
233221
</Text>
234222
))}
235223
{str3.split("").map((char, index) => (
236-
<Text key={index} backgroundColor={bg} {...lowlightStyle} {...shikiStyle}>
224+
<Text key={index} {...lowlightStyle} {...shikiStyle}>
237225
{char}
238226
</Text>
239227
))}
240228
</React.Fragment>
241229
);
242230
}
243231
})}
244-
{" "
245-
.padEnd(height * width - rawLine.length)
246-
.split("")
247-
.map((char, index) => (
248-
<Text key={char + "-" + index} backgroundColor={bg}>
249-
{char}
250-
</Text>
251-
))}
252232
</Box>
253233
{isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (
254-
<Box width={width - 1}>
255-
<Text backgroundColor={bg} wrap="truncate">
256-
{"\\ No newline at end of file".padEnd(width)}
257-
</Text>
234+
<Box width={width - 1} backgroundColor={bg}>
235+
<Text wrap="truncate">{"\\ No newline at end of file".padEnd(width)}</Text>
258236
</Box>
259237
)}
260238
</>
261239
);
262240
}
263241

264242
return (
265-
<Box width={width - 1} flexWrap="wrap">
243+
<Box width={width - 1} flexWrap="wrap" backgroundColor={bg}>
266244
{syntaxLine?.nodeList?.map(({ node, wrapper }, index) => {
267245
const lowlightStyles = getStyleFromClassName(wrapper?.properties?.className?.join(" ") || "");
268246
const lowlightStyle = theme === "dark" ? lowlightStyles.dark : lowlightStyles.light;
@@ -271,21 +249,13 @@ const DiffSyntax = ({
271249
return (
272250
<React.Fragment key={index}>
273251
{node.value.split("").map((char, index) => (
274-
<Text key={index} backgroundColor={bg} {...lowlightStyle} {...shikiStyle}>
252+
<Text key={index} {...lowlightStyle} {...shikiStyle}>
275253
{char}
276254
</Text>
277255
))}
278256
</React.Fragment>
279257
);
280258
})}
281-
{" "
282-
.padEnd(height * width - rawLine.length)
283-
.split("")
284-
.map((char, index) => (
285-
<Text key={index} backgroundColor={bg}>
286-
{char}
287-
</Text>
288-
))}
289259
</Box>
290260
);
291261
};

packages/cli/test/index.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { getDiffViewHighlighter } from "@git-diff-view/shiki";
2-
// import { createElement } from "@my-react/react";
3-
// import { render } from "@my-react/react-terminal";
4-
import { render } from "ink";
5-
import { createElement } from "react";
2+
import { createElement } from "@my-react/react";
3+
import { render } from "@my-react/react-terminal";
4+
// import { render } from "ink";
5+
// import { createElement } from "react";
66

77
import { DiffView, DiffModeEnum } from "@git-diff-view/cli";
88

@@ -62,11 +62,11 @@ index 5b301628..15aac42f 100644
6262
getDiffViewHighlighter().then((highlighter) => {
6363
render(
6464
createElement(DiffView, {
65-
data: { hunks: [hunks], newFile: { fileLang: "tsx" } },
65+
data: { hunks: [hunks], newFile: { fileLang: 'tsx' } },
6666
diffViewTheme: "light",
6767
diffViewHighlight: true,
6868
registerHighlighter: highlighter,
69-
diffViewMode: DiffModeEnum.SplitGitLab,
69+
diffViewMode: DiffModeEnum.Split,
7070
})
7171
);
7272
});

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)