- if len(args) == 2 and insert:
- cmd_name, remains = insert.split(_SEP_0, maxsplit=1)
- if cmd_name == _MARK_ANCHOR:
- continue
- args_ = list(self._args_for_cmd(cmd_name, remains))
- if args[1][0] in '+-':
- args_[0] = _SEP_1.join(
- str(int(n) + int(args[1]))
- for n in args_[0].split(_SEP_1) if n
- ) or ','
- else:
- args_[0] = args[1]
+ cmd_name, remains = insert.split(_SEP_0, maxsplit=1)
+ if cmd_name == _MARK_ANCHOR: # anchors should be unique,
+ continue # so avoid their repittion
+ args_idx = _SIGNATURE_FOR_CMD[cmd_name][1]
+ args_ = list(self._args_for_cmd(cmd_name, remains))
+ if len(args) == 2\
+ and args_idx is not None\
+ and len(args_) > args_idx:
+ args_[args_idx] = _SEP_1.join(
+ str(int(n) + int(args[1]))
+ for n in args_[args_idx].split(_SEP_1) if n
+ ) or ','