Skip to content

24 add insert at operation for inserting into a list at a specific index#28

Merged
nathanjmcdougall merged 8 commits into
mainfrom
24-add-insert_at-operation-for-inserting-into-a-list-at-a-specific-index
May 19, 2026
Merged

24 add insert at operation for inserting into a list at a specific index#28
nathanjmcdougall merged 8 commits into
mainfrom
24-add-insert_at-operation-for-inserting-into-a-list-at-a-specific-index

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new “insert at index” capability for YAML block sequences, exposed through the Python Document/Editor APIs and implemented in the Rust patch-application pipeline to preserve round-tripping behavior (especially comments/formatting).

Changes:

  • Add Document.insert(..., index, value) and Editor.insert(..., index, value) with Python list.insert()-style index semantics (negative indices, clamping).
  • Introduce a new core operation Op.insert_at implemented as a local (non-yamlpatch) op and routed through apply_patches_impl.
  • Add test coverage across core ops, document/editor APIs, and an integration scenario (pre-commit repo insertion).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_integration.py Adds an end-to-end test for inserting a repo into a pre-commit config list.
tests/test_editor.py Adds editor-level tests for insert() behavior and persistence to disk.
tests/test_document.py Adds document-level tests for insert() semantics and error cases.
tests/test_core_ops.py Adds core operation constructor + apply_patches tests for insert_at.
src/yamltrip/editor.py Adds Editor.insert() wrapper around Document.insert().
src/yamltrip/document.py Adds immutable Document.insert() API that emits an Op.insert_at patch.
src/yamltrip/_core.pyi Updates native-module type stubs with Op.insert_at.
src/ops.rs Adds LocalOp / OpInner to support local-only ops and implements Op.insert_at.
src/document.rs Routes local ops in apply_patches_impl and implements apply_insert_at string surgery.
doc/specs/2026-05-19-insert-operation-design.md Design spec documenting the API, routing approach, and algorithm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/document.rs
@nathanjmcdougall nathanjmcdougall merged commit ca6216c into main May 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add insert_at operation for inserting into a list at a specific index

2 participants