-
Notifications
You must be signed in to change notification settings - Fork 83
Editor: Inline Git Diff Rendering with Context Menu Toggle #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
20f1c09
0f8f4e1
b428b22
299fbfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ interface LineGutterProps { | |
isBreakpoint?: boolean; | ||
hasError?: boolean; | ||
hasWarning?: boolean; | ||
isDeleted?: boolean; | ||
oldLineNumber?: number; | ||
newLineNumber?: number; | ||
} | ||
|
||
export const LineGutter = ({ | ||
|
@@ -19,6 +22,8 @@ export const LineGutter = ({ | |
isBreakpoint = false, | ||
hasError = false, | ||
hasWarning = false, | ||
isDeleted = false, | ||
newLineNumber, | ||
}: LineGutterProps) => { | ||
const gutterDecorations = decorations.filter( | ||
(d) => d.type === "gutter" && d.range.start.line === lineNumber, | ||
|
@@ -55,7 +60,7 @@ export const LineGutter = ({ | |
className={cn("gutter-decoration", decoration.className)} | ||
style={{ | ||
position: "absolute", | ||
left: "2px", // Small gap from left edge | ||
left: "-4px", // Small gap from left edge | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this makes an inverted gap I guess? this comment can be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sticks the git gutter to the left end this way. Will see if there is something better that can be done. |
||
top: decoration.className?.includes("git-gutter-deleted") ? "0px" : "50%", | ||
transform: decoration.className?.includes("git-gutter-deleted") | ||
? "none" | ||
|
@@ -99,24 +104,42 @@ export const LineGutter = ({ | |
))} | ||
|
||
{/* Line numbers */} | ||
{showLineNumbers && ( | ||
<span | ||
className="line-number" | ||
style={{ | ||
position: "relative", | ||
zIndex: 2, | ||
fontSize: "12px", | ||
color: "var(--color-text-lighter, #6b7280)", | ||
fontFamily: "inherit", | ||
userSelect: "none", | ||
textAlign: "right", | ||
minWidth: `${gutterWidth - 24}px`, // Account for git indicator space and padding | ||
paddingLeft: "12px", // Space from git indicators | ||
}} | ||
> | ||
{lineNumber + 1} | ||
</span> | ||
)} | ||
{showLineNumbers && | ||
(newLineNumber !== undefined ? ( | ||
<div | ||
className="line-number-container" | ||
style={{ | ||
position: "relative", | ||
zIndex: 2, | ||
fontSize: "12px", | ||
color: "var(--color-text-lighter, #6b7280)", | ||
fontFamily: "inherit", | ||
userSelect: "none", | ||
textAlign: "right", | ||
minWidth: `${gutterWidth - 24}px`, | ||
paddingLeft: "12px", | ||
}} | ||
> | ||
{newLineNumber} | ||
</div> | ||
) : !isDeleted ? ( | ||
<div | ||
className="line-number-container" | ||
style={{ | ||
position: "relative", | ||
zIndex: 2, | ||
fontSize: "12px", | ||
color: "var(--color-text-lighter, #6b7280)", | ||
fontFamily: "inherit", | ||
userSelect: "none", | ||
textAlign: "right", | ||
minWidth: `${gutterWidth - 24}px`, | ||
paddingLeft: "12px", | ||
}} | ||
> | ||
{lineNumber + 1} | ||
</div> | ||
) : null)} | ||
|
||
{/* Other decorations (breakpoints, errors, etc.) */} | ||
{otherDecorations | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing that every 0.5 seconds, why not do it on save of the buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because when you are editing the file and havn’t saved the file yet. It will still show you the git diff based upon the buffer changes