Description
Validate a cursor boundary and splice bounds.
A splice replaces part of a list and changes later positions. Cursor affinity defines which side of inserted content a boundary follows when the splice covers it.
Validate a cursor boundary and splice bounds.
When to use this tool
Use List Splice Cursor Affinity when you need a splice length, gap-fill, or cursor-mapping calculation.
How to use the tool and how it works
- Enter cursor, start, deleteCount, insertCount, affinity, length. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read newCursor, newLength. Use the output convention below.
Validate a cursor boundary and splice bounds. Keep cursors before start, shift those strictly after the deletion end, and map those at or within the replaced interval to start or start + insertCount according to affinity.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| cursor | Zero-based boundary position in [0, length], including the terminal boundary. | Required. Safe integer; minimum 0. |
| start | Start | Required. Safe integer; minimum 0. |
| deleteCount | Delete Count | Required. Safe integer; minimum 0. |
| insertCount | Insert Count | Required. Safe integer; minimum 0. |
| affinity | Placement before or after inserted content when cursor lies on or inside the replaced interval. | Required. Text; one of "before", "after"; maximum UTF-16 length 8192. |
| length | Length | Required. Safe integer; minimum 0. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| newCursor | Boundary cursor after applying the stated splice affinity. | Required. Safe integer. |
| newLength | New Length | Required. Safe integer. |
{
"input": {
"cursor": 3,
"start": 3,
"deleteCount": 0,
"insertCount": 2,
"affinity": "after",
"length": 5
},
"output": {
"newCursor": 5,
"newLength": 7
}
} Limitations and assumptions
- Both deletion endpoints use affinity, including a pure insertion at the cursor; this maps a boundary without changing list data.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Check the actual collection API's deletion clamping and cursor semantics before applying an edit.
References
Similar or alternative tools
- List: List Single Splice Length Delta
Clamp deleteCount to the available suffix length.
- List: List Single Element Rank Shift
Map movedFrom to movedTo.