Skip to content

Commit

Permalink
#4509 - In the Text-editing mode, when inserting a fragment after pre…
Browse files Browse the repository at this point in the history
…ssing Ctrl+V twice, the cursor is moved to another row (#4664)
  • Loading branch information
Guch1g0v authored May 29, 2024
1 parent 1e7c398 commit a00bf26
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,28 @@ export class SequenceMode extends BaseMode {
const chainsCollection = ChainsCollection.fromMonomers([
...drawingEntitiesManager.monomers.values(),
]);

const currentSequence = SequenceRenderer.currentChain;

const currentSequenceHasPhosphate =
currentSequence?.lastNonEmptyNode?.monomer?.monomerItem?.props?.Name ===
'Phosphate';

let nextCaretPosition =
SequenceRenderer.caretPosition + chainsCollection.length;

if (currentSequenceHasPhosphate) {
nextCaretPosition -= 1;
}

const modelChanges = this.insertNewSequenceFragment(chainsCollection);

modelChanges.addOperation(new ReinitializeModeOperation());

modelChanges.addOperation(
new RestoreSequenceCaretPositionOperation(
SequenceRenderer.caretPosition,
SequenceRenderer.caretPosition + chainsCollection.length,
nextCaretPosition,
),
);

Expand Down

0 comments on commit a00bf26

Please sign in to comment.