|
| 1 | +import * as vscode from 'vscode' |
| 2 | +import { |
| 3 | + EDIT_FORMAT_INSTRUCTIONS_BEFORE_AFTER, |
| 4 | + EDIT_FORMAT_INSTRUCTIONS_DIFF, |
| 5 | + EDIT_FORMAT_INSTRUCTIONS_TRUNCATED, |
| 6 | + EDIT_FORMAT_INSTRUCTIONS_WHOLE |
| 7 | +} from '../constants/edit-format-instructions' |
| 8 | + |
| 9 | +export const copy_edit_format_instructions_command = () => { |
| 10 | + return vscode.commands.registerCommand( |
| 11 | + 'codeWebChat.copyEditFormatInstructions', |
| 12 | + async () => { |
| 13 | + const config = vscode.workspace.getConfiguration('codeWebChat') |
| 14 | + |
| 15 | + const items: vscode.QuickPickItem[] = [ |
| 16 | + { label: 'Whole', description: 'Print entire files' }, |
| 17 | + { label: 'Truncated', description: 'Truncate unchanged parts' }, |
| 18 | + { |
| 19 | + label: 'Before and After', |
| 20 | + description: 'Git-style merge conflict markers' |
| 21 | + }, |
| 22 | + { label: 'Diff', description: 'Unified diffs' } |
| 23 | + ] |
| 24 | + |
| 25 | + const selected = await vscode.window.showQuickPick(items, { |
| 26 | + title: 'Copy Edit Format Instructions', |
| 27 | + placeHolder: 'Select edit format' |
| 28 | + }) |
| 29 | + |
| 30 | + if (!selected) { |
| 31 | + return |
| 32 | + } |
| 33 | + |
| 34 | + let instructions = '' |
| 35 | + switch (selected.label) { |
| 36 | + case 'Whole': |
| 37 | + instructions = |
| 38 | + config.get<string>('editFormatInstructionsWhole') || |
| 39 | + EDIT_FORMAT_INSTRUCTIONS_WHOLE |
| 40 | + break |
| 41 | + case 'Truncated': |
| 42 | + instructions = |
| 43 | + config.get<string>('editFormatInstructionsTruncated') || |
| 44 | + EDIT_FORMAT_INSTRUCTIONS_TRUNCATED |
| 45 | + break |
| 46 | + case 'Diff': |
| 47 | + instructions = |
| 48 | + config.get<string>('editFormatInstructionsDiff') || |
| 49 | + EDIT_FORMAT_INSTRUCTIONS_DIFF |
| 50 | + break |
| 51 | + case 'Before/After': |
| 52 | + instructions = |
| 53 | + config.get<string>('editFormatInstructionsBeforeAfter') || |
| 54 | + EDIT_FORMAT_INSTRUCTIONS_BEFORE_AFTER |
| 55 | + break |
| 56 | + } |
| 57 | + |
| 58 | + const xml = `<system>\n${instructions}\n</system>` |
| 59 | + await vscode.env.clipboard.writeText(xml) |
| 60 | + |
| 61 | + vscode.window.showInformationMessage( |
| 62 | + 'Edit format instructions copied to clipboard' |
| 63 | + ) |
| 64 | + } |
| 65 | + ) |
| 66 | +} |
0 commit comments