MCPcopy Create free account
hub / github.com/modem-dev/hunk / nextNavigationKey

Function nextNavigationKey

benchmarks/navigation-memory.ts:182–203  ·  view source on GitHub ↗

Resolve the next keyboard action and logical position for one hunk-per-file navigation.

(
  position: number,
  direction: number,
  options: CliOptions,
)

Source from the content-addressed store, hash-verified

180
181/** Resolve the next keyboard action and logical position for one hunk-per-file navigation. */
182function nextNavigationKey(
183 position: number,
184 direction: number,
185 options: CliOptions,
186): { key: "]" | "["; position: number; direction: number } {
187 if (options.mode === "forward") {
188 return { key: "]", position: Math.min(options.fileCount - 1, position + 1), direction: 1 };
189 }
190
191 let nextDirection = direction;
192 if (position >= options.fileCount - 1) {
193 nextDirection = -1;
194 } else if (position <= 0) {
195 nextDirection = 1;
196 }
197
198 return {
199 key: nextDirection > 0 ? "]" : "[",
200 position: Math.max(0, Math.min(options.fileCount - 1, position + nextDirection)),
201 direction: nextDirection,
202 };
203}
204
205async function renderOnce(setup: Awaited<ReturnType<typeof testRender>>) {
206 await act(async () => {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected