()
| 138 | } |
| 139 | |
| 140 | function 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 | |
| 172 | let dir: string; |
| 173 | let cg: CodeGraph; |
no test coverage detected