goLeft method

ZipperLocation<ZR, ZI, ZS> goLeft()

Move to the sibling on the left

Implementation

ZipperLocation<ZR, ZI, ZS> goLeft() {
  if (path is TopPath) {
    throw Exception("Left of top");
  }
  NodePath<ZS, ZR> p = path as NodePath<ZS, ZR>;
  if (p.left.isEmpty) {
    throw Exception("left of first");
  }
  ZR l = p.left.first;
  final newLeft = List<ZR>.unmodifiable(p.left.skip(1));
  final newRight = List<ZR>.unmodifiable([node, ...p.right]);
  return update(
    node: l,
    path: NodePath(
      left: newLeft,
      right: newRight,
      parentPath: p.parentPath,
      parentNode: p.parentNode,
    ),
  );
}