Skip to content

fix: remove incorrect start/end swap in Tree.Offset#612

Open
doganarif wants to merge 1 commit intocharmbracelet:masterfrom
doganarif:fix-tree-offset
Open

fix: remove incorrect start/end swap in Tree.Offset#612
doganarif wants to merge 1 commit intocharmbracelet:masterfrom
doganarif:fix-tree-offset

Conversation

@doganarif
Copy link
Copy Markdown

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

Tree.Offset(start, end) swaps the values when start > end, treating them as a range. They are independent skip counts (beginning and end of the children list), so the swap silently produces wrong output.

For example, Offset(2, 1) on [A, B, C, D, E] was swapped to Offset(1, 2), giving [B, C] instead of the correct [C, D].

Removes the swap, adds tests covering start > end, equal offsets, and zero offsets.

Fixes #535

Offset(start, end) takes independent skip counts for the beginning
and end of the children list. The swap logic treated them as a
range, silently reversing the values when start > end.

Fixes charmbracelet#535
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.

Tree Offset logic is broken

1 participant