Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ class Editor implements KetcherEditor {

const rnaComponentToAssign = beginAtomRnaComponent ?? endAtomRnaComponent;
const struct = this.struct();
const atomIdToStartFrom = beginAtomRnaComponent ? bond.begin : bond.end;
const atomIdToStartFrom = beginAtomRnaComponent ? bond.end : bond.begin;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct — the previous code seeded the traversal from the atom already assigned to the component, so it walked through component atoms first and could incorrectly trip hasConnectionToOriginalStructure for connections that have nothing to do with the new bond. Two suggestions while this line is being touched:

  1. Rename atomIdToStartFromunassignedAtomId (or similar). The intent — "start from the unassigned endpoint" — would then be self-documenting, and the ternary's direction obvious by inspection. This is exactly the kind of bug that name-driven clarity prevents from regressing.
  2. Consider adding a focused unit test for this function. The three branches (no component / one component / two components) plus the "unassigned side reaches the original structure" case are highly testable, and a regression test would lock in this silent semantic inversion.

const visitedAtomIds = new Set<number>();
const atomsToCheck = [atomIdToStartFrom];
let hasConnectionToAnotherComponent = false;
Expand Down
Loading