def _execute_jump(view, jump_forward, only_other):
    """
    Add the selection to the fields and move the selection to the
    next field.
    """
    regions = view.get_regions("meu_sf_stored_selections")

    try:
        # search for the first field, which is behind the last selection
        end = max(sel.end() for sel in view.sel())
        pos = next(i for i, sel in enumerate(regions) if sel.begin() > end)
    except:
        # if there is no remaining field move the position behind the regions
        pos = len(regions)
    # insert the selection into the region
    if only_other:
        sel_count = 0
    else:
        sel_count = len(view.sel())
        if sel_count == 1:
            # handle special case of one selection
            regions.insert(pos, view.sel()[0])
        else:
            # put the selections into the regions array
            regions = regions[:pos] + list(view.sel()) + regions[pos:]
    # the forward jump must jump over all added selections
    delta = sel_count if jump_forward else -1
    # move the position to the next field
    pos = pos + delta
    return regions, pos
dataset/ETHPy150Open philippotto/Sublime-MultiEditUtils/selection_fields.py/_execute_jump/original