Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Fix bug where adding comment on opposite line would error
Open rudolfs opened 11 months ago

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.

check check-e2e check-unit-test

πŸ‘‰ Workflow runs πŸ‘‰ Branch on GitHub

1 file changed +10 -8 bb38192b β†’ e427af7e
modified src/components/Diff.svelte
@@ -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,