Skip to content

Commit

Permalink
Merge pull request #10 from dikopylov/fix-negative-offsets
Browse files Browse the repository at this point in the history
fix negative offset
  • Loading branch information
efureev authored Sep 16, 2021
2 parents 78120b2 + 9c18d12 commit 4ecb960
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Fixing.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function fixNodes(array &$dictionary, ?Model $parent = null)
{
$parentId = $parent ? $parent->getKey() : null;
$parentLevel = $parent ? $parent->levelValue() : 0;
$cut = $parent ? $parent->leftOffset() + 1 : 1;
$cut = $parent ? abs($parent->leftOffset()) + 1 : 1;

$updated = [];
$moved = 0;
Expand All @@ -84,8 +84,8 @@ protected function fixNodes(array &$dictionary, ?Model $parent = null)
$cut = self::reorderNodes($dictionary, $updated, $parentId, $cut, $parentLevel);
}

if ($parent && ($grown = $cut - $parent->rightOffset()) !== 0) {
$moved = $parent->newScopedQuery()->makeGap($parent->rightOffset() + 1, $grown);
if ($parent && ($grown = $cut - abs($parent->rightOffset())) !== 0) {
$moved = $parent->newScopedQuery()->makeGap(abs($parent->rightOffset()) + 1, $grown);

$updated[] = $parent->setAttribute($parent->rightAttribute()->name(), $cut);
}
Expand Down

0 comments on commit 4ecb960

Please sign in to comment.