Skip to content

Commit

Permalink
Merge pull request #1 from LucaJaich/main
Browse files Browse the repository at this point in the history
Polishing
  • Loading branch information
timkmecl authored Dec 7, 2022
2 parents 00179be + de8852c commit 24b0ad1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Once you have obtained a session token, you can configure the extension to use i

To use the extension, open a text editor in Visual Studio Code and open the ChatGPT panel by clicking on the ChatGPT icon in the sidebar. This will open a panel with an input field where you can enter your prompt or question. By clicking enter, it will be sent to ChatGPT. Its response will be displayed below the input field in the sidebar (note that it may take some time for it to be calculated).

You can also select a code snippet in the editor and then enter a prompt in the side panel. The selected code will be automatically appended to your query when it is sent to the AI. This can be useful for generating code snippets or getting explanations for specific pieces of code.
You can also select a code snippet in the editor and then enter a prompt in the side panel, or right-click and select "Ask ChatGPT". The selected code will be automatically appended to your query when it is sent to the AI. This can be useful for generating code snippets or getting explanations for specific pieces of code.

To insert a code snippet from the AI's response into the editor, simply click on the code block in the panel. The code will be automatically inserted at the cursor position in the active editor.

Expand Down
4 changes: 4 additions & 0 deletions media/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
response = '';
break;
}
case "setPrompt": {
document.getElementById("prompt-input").value = message.value;
break;
}
}
});

Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
"title": "Session Token"
}
}
},
"menus": {
"editor/context": [
{
"command": "chatgpt.ask",
"when": "editorTextFocus",
"group": "navigation"
}
]
}
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ class ChatGPTViewProvider implements vscode.WebviewViewProvider {
searchPrompt = prompt;
}

// focus gpt activity from activity bar
vscode.commands.executeCommand('workbench.view.extension.chatgpt');

// modify the input tag to show the search prompt as input value
if (this._view) {
this._view.webview.postMessage({ type: 'setPrompt', value: searchPrompt });
}

console.log("sendMessage");
// Send the search prompt to the ChatGPTAPI instance and store the response
response = await this._chatGPTAPI.sendMessage(searchPrompt, {
Expand Down

0 comments on commit 24b0ad1

Please sign in to comment.