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:
Rūdolfs Ošiņš
2025-05-06 12:28:30 +02:00
parent bb38192b7e
commit e427af7ed2
+10 -8
View File
@@ -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,