def run(self, edit, mode="smart", jump_forward=True, only_other=False):
        if mode not in _valid_modes:
            sublime.error_message(
                "'{0}' is an invalid mode for 'selection_fields'.\n"
                "Valid modes are: [{1}]"
                .format(mode, ", ".join(_valid_modes))
            )
            return
        view = self.view
        has_regions = bool(view.get_regions("meu_sf_stored_selections"))
        do_push = {
            "pop": False,
            "remove": False,
            "push": True,
            "subtract": False,
            "add": False  # add is specially handled
        }.get(mode, not has_regions)
        # the regions, which should be selected after executing this command
        sel_regions = None

        if do_push:  # push or initial trigger with anything except pop
            sels = list(view.sel())
            border_pos = 0 if jump_forward else len(sels) - 1
            sel_regions = _change_selection(view, sels, border_pos)
        elif mode == "subtract":  # subtract selections from the pushed fields
            sel_regions = list(view.sel())
            pushed_regions = view.get_regions("meu_sf_stored_selections")
            regions = list(_subtract_selection(pushed_regions, sel_regions))
            _set_fields(view, regions)
        elif mode == "add":  # add selections to the pushed fields
            pushed_regions = view.get_regions("meu_sf_stored_selections")
            sel_regions = list(view.sel())
            _set_fields(view, sel_regions + pushed_regions)
        elif mode == "remove":  # remove pushed fields
            pop_regions = _restore_selection(view, only_other)
            sel_regions = list(view.sel()) if not only_other else pop_regions
        elif mode not in ["smart", "cycle"]:  # pop or toggle with region
            sel_regions = _restore_selection(view, only_other)
        else:  # smart or cycle
            # execute the jump
            regions, pos = _execute_jump(view, jump_forward, only_other)
            # if we are in the cycle mode force the position to be valid
            if mode == "cycle":
                pos = pos % len(regions)
            # check whether it is a valid position
            pos_valid = pos == pos % len(regions)
            if pos_valid:
                # move the selection to the new field
                sel_regions = _change_selection(view, regions, pos)
            else:
                # if we reached the end restore the selection and
                # remove the highlight regions
                sel_regions = _restore_selection(view, only_other)

        # change to the result selections, if they exists
        if sel_regions:
            view.sel().clear()
            if _ST3:
                view.sel().add_all(sel_regions)
            else:
                for sel in sel_regions:
                    view.sel().add(sel)
            view.show(sel_regions[0])
dataset/ETHPy150Open philippotto/Sublime-MultiEditUtils/selection_fields.py/SelectionFieldsCommand.run/original