Skip to content

Type Editor


Type Editor / @type-editor/dom-change-util / parse-change/should-adjust-change-end-to-selection

parse-change/should-adjust-change-end-to-selection

Functions

FunctionDescription

shouldAdjustChangeEndToSelection

Checks if change end should be adjusted to selection end.

Similar to start adjustment, when typing at the end of a selection, if the typed character matches the character at the selection end, the diff algorithm might place the change end before that matching character. This function detects that case.

The adjustment is needed when:

  • The detected change ends before the selection end
  • But is very close (within 2 positions) to the selection end
  • And the selection end is within the parsed range

When this condition is met, both endA and endB of the change are adjusted to match the selection boundary.