def do_action(view: View, defx: Defx, action_name: str, context: Context) -> bool: """ Do "action_name" action. """ actions = DEFAULT_ACTIONS if action_name not in actions: return True action = actions[action_name] if ActionAttr.MARK not in action.attr and view._selected_candidates: # Clear marks view._selected_candidates = [] view.redraw() action.func(view, defx, context) if action_name != 'repeat': view._prev_action = action_name if ActionAttr.MARK in action.attr: # Update marks view.redraw() elif ActionAttr.REDRAW in action.attr: # Redraw view.redraw(True) return False
def do_action(view: View, defx: Defx, action_name: str, context: Context) -> bool: """ Do "action_name" action. """ actions: typing.Dict[str, ActionTable] = defx._source.kind.get_actions() if action_name not in actions: return True action = actions[action_name] if ActionAttr.MARK not in action.attr and view._selected_candidates: # Clear marks view._selected_candidates = [] view.redraw() action.func(view, defx, context) if action_name != 'repeat': view._prev_action = action_name if ActionAttr.MARK in action.attr: # Update marks view.redraw() elif ActionAttr.REDRAW in action.attr: # Redraw view.redraw(True) return False
def _cd(view: View, defx: Defx, context: Context) -> None: """ Change the current directory. """ path = context.args[0] if context.args else expand('~') path = os.path.normpath(os.path.join(defx._cwd, path)) if not os.path.isdir(path): error(view._vim, '{} is not directory'.format(path)) return view.cd(defx, path, context.cursor) view._selected_candidates = []
def _cd(view: View, defx: Defx, context: Context) -> None: """ Change the current directory. """ path = Path(context.args[0]) if context.args else Path.home() path = Path(defx._cwd).joinpath(path).resolve() if not path.is_dir(): error(view._vim, f'{path} is not directory') return prev_cwd = defx._cwd view.cd(defx, str(path), context.cursor) view._selected_candidates = [] if context.args and context.args[0] == '..': view.search_file(prev_cwd, defx._index)