-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f74b50d
commit 0d2cb56
Showing
12 changed files
with
290 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { DiffFileExtends } from "../diff"; | ||
import { useSyncHeight } from "../hooks/useSyncHeight"; | ||
import { SplitSide } from "./DiffSplitView"; | ||
import { emptyBGName } from "./color"; | ||
|
||
export const DiffSplitExtendLine = ({ | ||
index, | ||
diffFile, | ||
isWrap, | ||
side, | ||
lineNumber, | ||
}: { | ||
index: number; | ||
side: SplitSide; | ||
diffFile: DiffFileExtends; | ||
lineNumber: number; | ||
isWrap: boolean; | ||
isHighlight: boolean; | ||
}) => { | ||
const currentLeftExtend = diffFile.getSplitExtendLine(index, "left"); | ||
|
||
const currentRightExtend = diffFile.getSplitExtendLine(index, "right"); | ||
|
||
const currentIsShow = currentLeftExtend || currentRightExtend; | ||
|
||
useSyncHeight({ | ||
selector: `tr[data-line="${lineNumber}-extend"]`, | ||
side: side === SplitSide.old ? "left" : "right", | ||
enable: !!currentIsShow, | ||
}); | ||
|
||
if (!currentIsShow) return null; | ||
|
||
const currentExtend = | ||
side === SplitSide.old ? currentLeftExtend : currentRightExtend; | ||
|
||
return ( | ||
<tr | ||
data-line={`${lineNumber}-extend`} | ||
data-state="hunk" | ||
data-side={side === SplitSide.old ? "left" : "right"} | ||
className="diff-line diff-line-extend" | ||
style={{ | ||
backgroundColor: !currentExtend ? `var(${emptyBGName})` : undefined, | ||
}} | ||
> | ||
<td | ||
className="diff-line-extend-content" | ||
style={{ position: isWrap ? "relative" : "sticky" }} | ||
colSpan={2} | ||
> | ||
{currentExtend} | ||
</td> | ||
</tr> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { DiffFileExtends } from "../diff"; | ||
|
||
export const DiffUnifiedExtendLine = ({ | ||
index, | ||
diffFile, | ||
isWrap, | ||
}: { | ||
index: number; | ||
diffFile: DiffFileExtends; | ||
lineNumber: number; | ||
isWrap: boolean; | ||
isHighlight: boolean; | ||
}) => { | ||
const currentExtend = diffFile.getUnifiedExtendLine(index); | ||
|
||
if (!currentExtend) return null; | ||
|
||
return ( | ||
<tr | ||
data-state="extend" | ||
className="diff-line diff-line-extend" | ||
> | ||
<td | ||
className="diff-line-extend-content" | ||
style={{ position: isWrap ? "relative" : "sticky" }} | ||
colSpan={4} | ||
> | ||
{currentExtend} | ||
</td> | ||
</tr> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.