Skip to content

Commit 6b8190b

Browse files
committed
fix inserting code wtih VSCode snippet syntax
1 parent e4cbc0d commit 6b8190b

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ This Visual Studio Code extension allows you to use the [official OpenAI API](ht
1616

1717
<br>
1818

19-
*This is currently a work-in-progress, if there are any problems please let me know. You can also try [ChatGPT extension](https://github.com/timkmecl/chatgpt-vscode) ([marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.chatgpt)) which is smarter, but the setup is more complicated and it may not work (403/429 errors)*
19+
<a href="https://www.buymeacoffee.com/timkmecl" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px" ></a>
20+
21+
*This extension is free, however you need an OpenAI Account. You can also try [ChatGPT extension](https://github.com/timkmecl/chatgpt-vscode) ([marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.chatgpt)) which is smarter but currently doesn't work for most users.*
2022

2123
<br>
2224

2325
<img src="examples/main.png" alt="Refactoring selected code using chatGPT"/>
2426

2527
## Features
26-
- 💡 **Ask general questions** or use code snippets from the editor to query ChatGPT via an input box in the sidebar
28+
- 💡 **Ask general questions** or use code snippets from the editor to query GPT3 via an input box in the sidebar
2729
- 🖱️ Right click on a code selection and run one of the context menu **shortcuts**
2830
- automatically write documentation for your code
2931
- explain the selected code
3032
- refactor or optimize it
3133
- find problems with it
32-
- 💻 View ChatGPT's responses in a panel next to the editor
34+
- 💻 View GPT's responses in a panel next to the editor
3335
- 📝 **Insert code snippets** from the AI's response into the active editor by clicking on them
3436

3537

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "codegpt3",
33
"displayName": "CodeGPT: write and improve code using AI",
44
"description": "Use GPT3 right inside the IDE to enhance and automate your coding with AI-powered assistance",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"publisher": "timkmecl",
77
"icon": "resources/extensionIcon.png",
88
"license": "MIT",

src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ class CodeGPTViewProvider implements vscode.WebviewViewProvider {
161161
break;
162162
}
163163
let code = data.value;
164-
code = code.replace(/([^\\])(\$)([^{0-9])/g, "$1\\$$$3");
164+
//code = code.replace(/([^\\])(\$)([^{0-9])/g, "$1\\$$$3");
165+
const snippet = new vscode.SnippetString();
166+
snippet.appendText(code);
165167
// insert the code as a snippet into the active text editor
166-
vscode.window.activeTextEditor?.insertSnippet(new vscode.SnippetString(code));
168+
vscode.window.activeTextEditor?.insertSnippet(snippet);
167169
break;
168170
}
169171
case 'prompt':

0 commit comments

Comments
 (0)