MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / handleNormalInput

Function handleNormalInput

src/vim/transitions.ts:98–200  ·  view source on GitHub ↗

* Handle input that's valid in both idle and count states. * Returns null if input is not recognized.

(
  input: string,
  count: number,
  ctx: TransitionContext,
)

Source from the content-addressed store, hash-verified

96 * Returns null if input is not recognized.
97 */
98function handleNormalInput(
99 input: string,
100 count: number,
101 ctx: TransitionContext,
102): TransitionResult | null {
103 if (isOperatorKey(input)) {
104 return { next: { type: 'operator', op: OPERATORS[input], count } }
105 }
106
107 if (SIMPLE_MOTIONS.has(input)) {
108 return {
109 execute: () => {
110 const target = resolveMotion(input, ctx.cursor, count)
111 ctx.setOffset(target.offset)
112 },
113 }
114 }
115
116 if (FIND_KEYS.has(input)) {
117 return { next: { type: 'find', find: input as FindType, count } }
118 }
119
120 if (input === 'g') return { next: { type: 'g', count } }
121 if (input === 'r') return { next: { type: 'replace', count } }
122 if (input === '>' || input === '<') {
123 return { next: { type: 'indent', dir: input, count } }
124 }
125 if (input === '~') {
126 return { execute: () => executeToggleCase(count, ctx) }
127 }
128 if (input === 'x') {
129 return { execute: () => executeX(count, ctx) }
130 }
131 if (input === 'J') {
132 return { execute: () => executeJoin(count, ctx) }
133 }
134 if (input === 'p' || input === 'P') {
135 return { execute: () => executePaste(input === 'p', count, ctx) }
136 }
137 if (input === 'D') {
138 return { execute: () => executeOperatorMotion('delete', '$', 1, ctx) }
139 }
140 if (input === 'C') {
141 return { execute: () => executeOperatorMotion('change', '$', 1, ctx) }
142 }
143 if (input === 'Y') {
144 return { execute: () => executeLineOp('yank', count, ctx) }
145 }
146 if (input === 'G') {
147 return {
148 execute: () => {
149 // count=1 means no count given, go to last line
150 // otherwise go to line N
151 if (count === 1) {
152 ctx.setOffset(ctx.cursor.startOfLastLine().offset)
153 } else {
154 ctx.setOffset(ctx.cursor.goToLine(count).offset)
155 }

Callers 2

fromIdleFunction · 0.85
fromCountFunction · 0.85

Calls 15

isOperatorKeyFunction · 0.85
resolveMotionFunction · 0.85
executeToggleCaseFunction · 0.85
executeXFunction · 0.85
executeJoinFunction · 0.85
executePasteFunction · 0.85
executeOperatorMotionFunction · 0.85
executeLineOpFunction · 0.85
executeRepeatFindFunction · 0.85
executeOpenLineFunction · 0.85
startOfLastLineMethod · 0.80
goToLineMethod · 0.80

Tested by

no test coverage detected