MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / helperSource

Function helperSource

__tests__/explore-same-basename-pin.test.ts:140–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138}
139
140function helperSource(): string {
141 const L: string[] = [
142 'export interface ITextEditorViewState { scrollTop: number; cursor: number }',
143 '',
144 'export function applyTextEditorOptions(options: { selection?: number; viewState?: ITextEditorViewState }, editor: { reveal(line: number): void; restore(s: ITextEditorViewState): void }): boolean {',
145 ' if (options.viewState) {',
146 ' editor.restore(massageEditorViewState(options.viewState));',
147 ' return true;',
148 ' }',
149 ' if (typeof options.selection === "number") {',
150 ' editor.reveal(options.selection);',
151 ' return true;',
152 ' }',
153 ' return false;',
154 '}',
155 '',
156 'function massageEditorViewState(state: ITextEditorViewState): ITextEditorViewState {',
157 ' return { scrollTop: Math.max(0, state.scrollTop), cursor: Math.max(0, state.cursor) };',
158 '}',
159 ];
160 for (let i = 0; i < 12; i++) {
161 L.push(
162 '',
163 `export function restoreEditorGroup${i}(state: ITextEditorViewState): number {`,
164 ` const offset = state.scrollTop * ${i + 2} + state.cursor;`,
165 ` return offset > ${100 * (i + 1)} ? offset - ${i} : offset + ${i};`,
166 '}',
167 );
168 }
169 return L.join('\n') + '\n';
170}
171
172let dir: string;
173let cg: CodeGraph;

Calls 2

pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected