MCPcopy Create free account
hub / github.com/anus-dev/ANUS / vimReducer

Function vimReducer

packages/cli/src/ui/hooks/vim.ts:76–112  ·  view source on GitHub ↗
(state: VimState, action: VimAction)

Source from the content-addressed store, hash-verified

74
75// Reducer function
76const vimReducer = (state: VimState, action: VimAction): VimState => {
77 switch (action.type) {
78 case 'SET_MODE':
79 return { ...state, mode: action.mode };
80
81 case 'SET_COUNT':
82 return { ...state, count: action.count };
83
84 case 'INCREMENT_COUNT':
85 return { ...state, count: state.count * DIGIT_MULTIPLIER + action.digit };
86
87 case 'CLEAR_COUNT':
88 return { ...state, count: 0 };
89
90 case 'SET_PENDING_OPERATOR':
91 return { ...state, pendingOperator: action.operator };
92
93 case 'SET_LAST_COMMAND':
94 return { ...state, lastCommand: action.command };
95
96 case 'CLEAR_PENDING_STATES':
97 return {
98 ...state,
99 ...createClearPendingState(),
100 };
101
102 case 'ESCAPE_TO_NORMAL':
103 // Handle escape - clear all pending states (mode is updated via context)
104 return {
105 ...state,
106 ...createClearPendingState(),
107 };
108
109 default:
110 return state;
111 }
112};
113
114/**
115 * React hook that provides vim-style editing functionality for text input.

Callers

nothing calls this directly

Calls 1

createClearPendingStateFunction · 0.85

Tested by

no test coverage detected