p-doom/crowd-code-dataset-0.2 huggingface dataset:
[content] crowd-pilot-extension/src/extension.ts (typescript)
	const next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections' || action.kind === 'openFile') ? action : undefined;
[content] crowd-pilot-extension/src/extension.ts (typescript)
	// FIXME (f.srambical): add file switch 
	const next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections') ? action : undefined;
[content] crowd-pilot-extension/src/extension.ts (typescript)
	} else if (next.kind === 'openFile') {
		const cursor = editor.selection.active;
		const lineEnd = editor.document.lineAt(cursor.line).range.end;
		const fileName = next.filePath.split(/[/\\]/).pop() || next.filePath;
		const label = `↳ Switch to file: ${fileName}`;
		const margin = getDynamicMargin(editor, cursor.line, label);

		decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({
			after: {
				contentText: '',
				color: new vscode.ThemeColor('charts.purple'),
				backgroundColor: new vscode.ThemeColor('editor.background'),
				fontStyle: 'italic',
				fontWeight: '600',
				margin: `0 0 0 ${margin}`,
				textDecoration: `none; display: inline-block; white-space: pre; content: "${label.replace(/"/g, '\\"')}"; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`
			}
		});
		editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);
[content] crowd-pilot-extension/src/extension.ts (typescript)
	if (action.kind === 'openFile') {
		const uri = vscode.Uri.file(action.filePath);
		const openedEditor = await vscode.window.showTextDocument(uri);
		if (action.line !== undefined) {
			const line0 = Math.max(0, action.line - 1); // Convert 1-based to 0-based
			const safeLineIndex = Math.min(line0, openedEditor.document.lineCount - 1);
			const pos = new vscode.Position(safeLineIndex, 0);
			openedEditor.selection = new vscode.Selection(pos, pos);
			openedEditor.revealRange(new vscode.Range(pos, pos), vscode.TextEditorRevealType.InCenter);
		}
		return;
	}
[content] crowd-pilot-extension/src/extension.ts (typescript)
		// File switch with viewport: open at the center of the requested range
		const centerLine1 = Math.floor((startLine1 + endLine1) / 2);
		return { kind: 'openFile', filePath: targetFile, line: centerLine1 };
[content] crowd-pilot-extension/src/extension.ts (typescript)
	} else if (next.kind === 'openFile') {
		const cursor = editor.selection.active;
		const lineEnd = editor.document.lineAt(cursor.line).range.end;
		const fileName = next.filePath.split(/[/\\]/).pop() || next.filePath;
		const label = next.line !== undefined
			? `↳ Switch to file: ${fileName}:${next.line}`
			: `↳ Switch to file: ${fileName}`;
		const margin = getDynamicMargin(editor, cursor.line, label);

		decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({
			after: {
				contentText: '',
				color: new vscode.ThemeColor('charts.purple'),
				backgroundColor: new vscode.ThemeColor('editor.background'),
				fontStyle: 'italic',
				fontWeight: '600',
				margin: `0 0 0 ${margin}`,
				textDecoration: `none; display: inline-block; white-space: pre; content: "${label.replace(/"/g, '\\"')}"; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`
			}
		});
		editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);
[content] crowd-pilot-extension/src/extension.ts (typescript)

		if (action.line !== undefined) {
			const line0 = Math.max(0, action.line - 1); // Convert 1-based to 0-based
			const safeLineIndex = Math.min(line0, openedEditor.document.lineCount - 1);
			const pos = new vscode.Position(safeLineIndex, 0);
			openedEditor.selection = new vscode.Selection(pos, pos);
			openedEditor.revealRange(new vscode.Range(pos, pos), vscode.TextEditorRevealType.InCenter);
		}
[content] crowd-pilot-extension/src/extension.ts (typescript)
	if (action.kind === 'openFile') {
		const uri = vscode.Uri.file(action.filePath);
		const openedEditor = await vscode.window.showTextDocument(uri);
		if (action.selections && action.selections.length > 0) {
			openedEditor.selections = action.selections.map(s => new vscode.Selection(
				new vscode.Position(s.start[0], s.start[1]),
				new vscode.Position(s.end[0], s.end[1])
			));
			openedEditor.revealRange(openedEditor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
		}
		return;
	}
[content] crowd-pilot-extension/src/extension.ts (typescript)
		// File switch with viewport: open at the center of the requested range (0-based)
		const center1 = Math.floor((startLine1 + endLine1) / 2);
		const center0 = Math.max(0, center1 - 1);
		return {
			kind: 'openFile',
			filePath: targetFile,
			selections: [{ start: [center0, 0], end: [center0, 0] }]
		};
[content] crowd-pilot-extension/src/extension.ts (typescript)
	} else if (next.kind === 'openFile') {
		const cursor = editor.selection.active;
		const lineEnd = editor.document.lineAt(cursor.line).range.end;
		const fileName = next.filePath.split(/[/\\]/).pop() || next.filePath;
		const targetLine = next.selections?.[0]?.start[0];
		const label = targetLine !== undefined
			? `↳ Switch to file: ${fileName}:${targetLine + 1}` // Display as 1-based
			: `↳ Switch to file: ${fileName}`;
		const margin = getDynamicMargin(editor, cursor.line, label);

		decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({
			after: {
				contentText: '',
				color: new vscode.ThemeColor('charts.purple'),
				backgroundColor: new vscode.ThemeColor('editor.background'),
				fontStyle: 'italic',
				fontWeight: '600',
				margin: `0 0 0 ${margin}`,
				textDecoration: `none; display: inline-block; white-space: pre; content: "${label.replace(/"/g, '\\"')}"; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`
			}
		});
		editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(lineEnd, lineEnd) }]);
[content] crowd-pilot-extension/src/extension.ts (typescript)
	if (action.kind === 'openFile') {
		const uri = vscode.Uri.file(action.filePath);
		const openedEditor = await vscode.window.showTextDocument(uri);
		if (action.selections) {
			openedEditor.selections = action.selections.map(s => new vscode.Selection(
				new vscode.Position(s.start[0], s.start[1]),
				new vscode.Position(s.end[0], s.end[1])
			));
			openedEditor.revealRange(openedEditor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
		}
		return;
	}
[content] crowd-pilot-extension/src/extension.ts (typescript)
	} else if (next.kind === 'openFile') {
		const cursor = editor.selection.active;
		const anchorPos = new vscode.Position(cursor.line, Number.MAX_VALUE);
		const fileName = next.filePath.split(/[/\\]/).pop() || next.filePath;
		const targetLine = next.selections?.[0]?.start[0];
		const label = targetLine !== undefined
			? `↳ Switch to file: ${fileName}:${targetLine + 1}` // Display as 1-based
			: `↳ Switch to file: ${fileName}`;
		const margin = getDynamicMargin(editor, cursor.line, label);

		decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({
			after: {
				contentText: '',
				color: new vscode.ThemeColor('charts.purple'),
				backgroundColor: new vscode.ThemeColor('editor.background'),
				fontStyle: 'italic',
				fontWeight: '600',
				margin: `0 0 0 ${margin}`,
				textDecoration: `none; display: inline-block; white-space: pre; content: "${label.replace(/"/g, '\\"')}"; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`
			}
		});
		editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);
[content] crowd-pilot-extension/src/extension.ts (typescript)
	} else if (next.kind === 'openFile') {
		const cursor = editor.selection.active;
		const isVisible = editor.visibleRanges.some(r => r.contains(cursor));
		
		let anchorPos = new vscode.Position(cursor.line, Number.MAX_VALUE);
		
		// If cursor is not visible, anchor at viewport edge
		if (!isVisible && editor.visibleRanges.length > 0) {
			const firstVisible = editor.visibleRanges[0].start;
			const lastVisible = editor.visibleRanges[editor.visibleRanges.length - 1].end;
			
			if (cursor.isBefore(firstVisible)) {
				anchorPos = new vscode.Position(firstVisible.line, Number.MAX_VALUE);
			} else {
				anchorPos = new vscode.Position(lastVisible.line, Number.MAX_VALUE);
			}
		}
		
		const fileName = next.filePath.split(/[/\\]/).pop() || next.filePath;
		const targetLine = next.selections?.[0]?.start[0];
		const label = targetLine !== undefined
			? `↳ Switch to file: ${fileName}:${targetLine + 1}` // Display as 1-based
			: `↳ Switch to file: ${fileName}`;
		const margin = getDynamicMargin(editor, anchorPos.line, label);

		decorationReplaceBlockType = vscode.window.createTextEditorDecorationType({
			after: {
				contentText: '',
				color: new vscode.ThemeColor('charts.purple'),
				backgroundColor: new vscode.ThemeColor('editor.background'),
				fontStyle: 'italic',
				fontWeight: '600',
				margin: `0 0 0 ${margin}`,
				textDecoration: `none; display: inline-block; white-space: pre; content: "${label.replace(/"/g, '\\"')}"; border: 1px solid var(--vscode-charts-purple); padding: 4px; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.25); pointer-events: none; position: relative; z-index: 100; vertical-align: top;`
			}
		});
		editor.setDecorations(decorationReplaceBlockType, [{ range: new vscode.Range(anchorPos, anchorPos) }]);
[content] crowd-pilot-extension/src/extension.ts (typescript)
		const isVisible = editor.visibleRanges.some(r => r.contains(cursor));
		
		let anchorPos = new vscode.Position(cursor.line, Number.MAX_VALUE);
		
		// If cursor is not visible, anchor at viewport edge
		if (!isVisible && editor.visibleRanges.length > 0) {
			const firstVisible = editor.visibleRanges[0].start;
			const lastVisible = editor.visibleRanges[editor.visibleRanges.length - 1].end;
			
			if (cursor.isBefore(firstVisible)) {
				anchorPos = new vscode.Position(firstVisible.line, Number.MAX_VALUE);
			} else {
				anchorPos = new vscode.Position(lastVisible.line, Number.MAX_VALUE);
			}
		}