mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-02 02:00:31 +08:00
Fix bug where adding comment on opposite line would error
When adding a comment to the side that doesn't have changes we force the comment to be added to the opposite side. E.g. adding a comment on the right-hand-side for a deletion will force the comment to be added to the left-hand-side.
This commit is contained in:
@@ -141,32 +141,34 @@
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const commentAnchor = determineSelectedAnchor(side, line);
|
||||
|
||||
selection = {
|
||||
file: filePath(file, side),
|
||||
start: determineSelectedAnchor(side, line),
|
||||
end: determineSelectedAnchor(side, line),
|
||||
start: commentAnchor,
|
||||
end: commentAnchor,
|
||||
hunkIdx: hunkIdx,
|
||||
lineIdx: lineIdx,
|
||||
codeLocation: {
|
||||
commit: head,
|
||||
path: filePath(file, side),
|
||||
old:
|
||||
side === "left"
|
||||
commentAnchor.side === "left"
|
||||
? {
|
||||
type: "lines",
|
||||
range: {
|
||||
start: lineNumber(line, "left") as number,
|
||||
end: (lineNumber(line, "left") as number) + 1,
|
||||
start: commentAnchor.lineNumber,
|
||||
end: commentAnchor.lineNumber + 1,
|
||||
},
|
||||
}
|
||||
: null,
|
||||
new:
|
||||
side === "right"
|
||||
commentAnchor.side === "right"
|
||||
? {
|
||||
type: "lines",
|
||||
range: {
|
||||
start: lineNumber(line, "right") as number,
|
||||
end: (lineNumber(line, "right") as number) + 1,
|
||||
start: commentAnchor.lineNumber,
|
||||
end: commentAnchor.lineNumber + 1,
|
||||
},
|
||||
}
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user