11import * as vscode from 'vscode'
22import { FilesCollector } from '../utils/files-collector'
3- import { chat_code_completion_instructions } from '../constants/instructions'
4- import { replace_saved_context_placeholder } from '../utils/replace-saved-context-placeholder'
53
64async function perform_code_completion_to_clipboard (
75 context : vscode . ExtensionContext ,
86 file_tree_provider : any ,
9- open_editors_provider : any ,
10- with_instructions : boolean = false
7+ open_editors_provider : any
118) {
129 const editor = vscode . window . activeTextEditor
1310 if ( ! editor ) {
1411 vscode . window . showErrorMessage ( 'No active editor found.' )
1512 return
1613 }
1714
18- let completion_instructions : string | undefined
19- if ( with_instructions ) {
20- completion_instructions = await vscode . window . showInputBox ( {
21- placeHolder : 'Completion instructions' ,
22- prompt : 'E.g. "Include explanatory comments".'
23- } )
24-
25- // If user cancels the input box (not the same as empty input), return
26- if ( completion_instructions === undefined ) {
27- return
28- }
29- }
30-
3115 const document = editor . document
3216 const document_path = document . uri . fsPath
3317 const position = editor . selection . active
@@ -56,38 +40,7 @@ async function perform_code_completion_to_clipboard(
5640 after : `${ text_after_cursor } \n]]>\n</file>\n</files>`
5741 }
5842
59- const base_instructions = chat_code_completion_instructions (
60- relative_path ,
61- position . line ,
62- position . character
63- )
64-
65- let pre_instructions = base_instructions
66- let post_instructions = base_instructions
67-
68- if ( with_instructions && completion_instructions ) {
69- if ( completion_instructions . includes ( '@SavedContext:' ) ) {
70- const pre_user_instructions = await replace_saved_context_placeholder (
71- completion_instructions ,
72- context ,
73- file_tree_provider
74- )
75- const post_user_instructions = await replace_saved_context_placeholder (
76- completion_instructions ,
77- context ,
78- file_tree_provider ,
79- true
80- )
81- pre_instructions += ` Follow instructions: ${ pre_user_instructions } `
82- post_instructions += ` Follow instructions: ${ post_user_instructions } `
83- } else {
84- const user_instructions_part = ` Follow instructions: ${ completion_instructions } `
85- pre_instructions += user_instructions_part
86- post_instructions += user_instructions_part
87- }
88- }
89-
90- const content = `${ pre_instructions } \n${ payload . before } <missing text>${ payload . after } \n${ post_instructions } `
43+ const content = `${ payload . before } <missing text>${ payload . after } `
9144
9245 await vscode . env . clipboard . writeText ( content )
9346 vscode . window . showInformationMessage (
@@ -109,26 +62,7 @@ export function code_completion_to_clipboard_command(
10962 await perform_code_completion_to_clipboard (
11063 context ,
11164 file_tree_provider ,
112- open_editors_provider ,
113- false
114- )
115- }
116- )
117- }
118-
119- export function code_completion_with_instructions_to_clipboard_command (
120- context : vscode . ExtensionContext ,
121- file_tree_provider : any ,
122- open_editors_provider ?: any
123- ) {
124- return vscode . commands . registerCommand (
125- 'codeWebChat.codeCompletionWithInstructionsToClipboard' ,
126- async ( ) => {
127- await perform_code_completion_to_clipboard (
128- context ,
129- file_tree_provider ,
130- open_editors_provider ,
131- true
65+ open_editors_provider
13266 )
13367 }
13468 )
0 commit comments