You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add insert_at operation for inserting into a list at a specific index #24
There is currently no way to insert an item at a specific position in a YAML sequence while preserving comments on existing items. The only options are:
�ppend — adds at the end only
eplace the entire list — loses all internal comments
For example, inserting a pre-commit repo at index 1 (between two existing repos) currently requires replacing the entire
epos list, which destroys any comments within the existing items.
Proposal
Add an \insert_at\ method to \Document\ (and \Editor):
This would require a new \Op\ variant in the Rust layer (sibling to \�ppend):
\
ust
Op::InsertAt { index: usize, value: Value }
\\
The patcher would locate the byte position of the Nth item and insert the new content before it, matching the indentation of its siblings.
Use case
In usethis, pre-commit hooks have a defined ordering. When adding a new hook repo, it often needs to be inserted between existing repos rather than appended at the end. Without \insert_at, the workaround is a full list replacement via
eplace('repos', value=new_list), which loses all comments within the list.
Notes
Comments on existing items would be fully preserved since they are not touched.
The new item's indentation should match existing siblings (related to indentation inference in the patcher).
Activity
Add design spec for insert operation (#24)
24 add insert at operation for inserting into a list at a specific in…