Skip to content

Commit 94a458d

Browse files
committed
fix: diff shows line numbers for from
1 parent 639eaf5 commit 94a458d

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/workshop-app/app/routes/_app+/$exerciseNumber.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ export default function ExerciseNumberRoute() {
3434
'No instructions yet...'
3535
)}
3636
</div>
37-
<Link to="01/problem">Start</Link>
37+
<div className="flex justify-center p-6">
38+
<Link
39+
to="01/problem"
40+
prefetch="intent"
41+
className="rounded border-2 border-green-500 bg-green-600 px-3 py-2 text-gray-100 hover:bg-green-500 focus:bg-green-500"
42+
>
43+
Start
44+
</Link>
45+
</div>
3846
</div>
3947
)
4048
}

packages/workshop-app/app/routes/_app+/$exerciseNumber_.$stepNumber.$type.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,8 @@ export default function ExercisePartRoute() {
285285
)}
286286
</TabPanel>
287287
<TabPanel hidden={tabIndex !== 3}>
288-
<div>
289-
<div className="prose whitespace-pre-wrap">
290-
<Mdx code={data.diff.diffCode} />
291-
</div>
292-
<pre>{JSON.stringify(data, null, 2)}</pre>
288+
<div className="prose whitespace-pre-wrap">
289+
<Mdx code={data.diff.diffCode} />
293290
</div>
294291
</TabPanel>
295292
</TabPanels>

packages/workshop-app/app/utils/diff.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ function getFileCodeblocks(
4343
const removedLineNumbers = []
4444
const addedLineNumbers = []
4545
const lines = []
46-
const startLine = chunk.toFileRange.start
46+
const startLine =
47+
chunk.type === 'Chunk'
48+
? chunk.fromFileRange.start
49+
: chunk.type === 'CombinedChunk'
50+
? chunk.fromFileRangeA.start
51+
: 1
4752
for (let lineNumber = 0; lineNumber < chunk.changes.length; lineNumber++) {
4853
const change = chunk.changes[lineNumber]
4954
if (!change) continue

0 commit comments

Comments
 (0)