Skip to content

Commit dfb8eb4

Browse files
authored
Merge pull request #12880 from anandmeg/copilot-1711-a
Updates for 17.11 context features for GitHub Copilot Chat
2 parents ae08b4d + c35e13b commit dfb8eb4

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

docs/ide/copilot-chat-context.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Tips & Tricks for GitHub Copilot Chat in Visual Studio'
33
description: Use slash commands, references, and threads to form better questions and get better answers with scoped context in GitHub Copilot Chat.
4-
ms.date: 7/29/2024
4+
ms.date: 8/13/2024
55
ms.topic: how-to
66
author: anandmeg
77
ms.author: meghaanand
@@ -56,25 +56,42 @@ You can use slash commands in a [chat window](visual-studio-github-copilot-chat.
5656

5757
## <a name="reference"></a>Reference: scope Copilot results to a particular file or entire solution
5858

59-
You can ask your coding related questions in natural language and GitHub Copilot Chat will answer these in the context of the codebase open in Visual Studio. With references you can get more specific about the information you want Copilot to consider when answering your question. By selecting a specific context in your codebase, you're able to form better questions easily without having to write out or paste long pieces of information. Specifying the context also enables Copilot to provide you with more relevant answers.
59+
You can ask your coding related questions in natural language and GitHub Copilot Chat will answer these in the context of the codebase open in Visual Studio. With references you can get more specific about the information you want Copilot to consider when answering your question.
6060

61-
To easily reference a file, simply add a *#* symbol at the beginning of the file name. For example, if you have a file named *BasketService.cs*, refer to it in the chat as *#BasketService.cs*.
61+
By selecting a specific context in your codebase, you're able to form better questions easily without having to write out or paste long pieces of information. Specifying the context also enables Copilot to provide you with more relevant answers.
62+
63+
### Reference a file
64+
65+
To easily reference a file in GitHub Copilot Chat, simply add a *#* symbol at the beginning of the file name. For example, if you have a file named *BasketService.cs*, refer to it in the chat as *#BasketService.cs*.
6266

6367
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-hash-reference.png" alt-text="Screenshot of references in Copilot Chat.":::
6468

65-
Use *#solution* to refer to the solution active in the IDE for context.
69+
### Reference a method, class, or function
70+
71+
With [Visual Studio 2022 version 17.11](/visualstudio/releases/2022/release-notes), you can now reference a specific method, class, or function in GitHub Copilot Chat.
72+
73+
To easily reference a method, class, or function in GitHub Copilot Chat, simply add a *#* symbol at the beginning of the method, class, or function name. For example, if you have a method named *BasketAddItem*, refer to it in the chat as *#BasketAddItem*.
74+
75+
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-references-methods.png" alt-text="Screenshot of references to methods in GitHub Copilot Chat in Visual Studio.":::
76+
77+
### Reference the entire solution
78+
79+
Use *@workspace* to refer to the solution active in the IDE for context. When using *@workspace* for context, Copilot Chat leverages the information about the files, projects, and configurations that are currently open and being worked on within your IDE. This enables Copilot Chat to provide more relevant and context-aware suggestions and answers.
6680

67-
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-hash-solution-reference.gif" alt-text="Screenshot of referencing solution context in Copilot Chat.":::
81+
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-at-workspace.gif" alt-text="Screenshot of referencing solution context in Copilot Chat.":::
6882

83+
### Usage examples
6984
Here are some examples of using references for context control:
7085

7186
| **Example** | **Context used by Copilot to form the question** |
7287
|---------------------------|:--------------------:|
7388
| What is the purpose of #MyFile.cs: 66-72?| Exact section of the file |
7489
| Where are the tests in #BasketService.cs?| BasketService.cs |
75-
| /explain the AddItemToBasket method in #BasketService.cs| AddItemToBasket method in BasketService.cs |
76-
| Is there a delete basket method in this #solution| Current Solution open in the IDE|
77-
90+
| /explain the #AddItemToBasket in #BasketService.cs| AddItemToBasket method in BasketService.cs |
91+
| Is there a delete basket method in this @workspace| Current solution open in the IDE |
92+
| I have a test method named #TestCalculator. How can I ensure that it's being executed correctly?| TestCalculator method |
93+
| Could you explain the differences between classes #BasketService and #OrderService?| BasketService class and OrderService class |
94+
| In my @workspace where is #AddItemToBasket? | Current solution open in the IDE |
7895

7996
## <a name="find-context"></a>Review the sources used by Copilot Chat
8097

@@ -86,14 +103,24 @@ Copilot Chat displays the context it used after every result, so that you can te
86103

87104
If you’re using Copilot Chat extensively to ask questions as you code, you can organize your conversations in a way that keeps them on-topic. Copilot Chat for Visual Studio now provides an easy way to start new conversations (threads) to keep them focused on the task at hand, and keep the context clear so the answers are based on relevant history.
88105

106+
### <a name="new-thread"></a>New chat thread
107+
89108
You can start a new thread by selecting the **Create new thread** in the chat window.
90109

91110
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-new-thread-conversation.png" alt-text="Screenshot of Create new thread icon in Copilot Chat.":::
92111

112+
### <a name="switch-thread"></a>Switch chat thread
113+
93114
You can select between multiple ongoing threads to provide the right historical context for your question.
94115

95116
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-switch-threads.png" alt-text="Screenshot of switching between ongoing threads in Copilot Chat.":::
96117

118+
### <a name="promote-inline"></a>Promote inline chat to the chat window
119+
120+
With [Visual Studio 2022 version 17.11](/visualstudio/releases/2022/release-notes), you can now preserve the history of your [inline chat](visual-studio-github-copilot-chat.md#ask-questions-in-the-inline-chat-view) by promoting it to the [chat window](visual-studio-github-copilot-chat.md#ask-questions-in-the-chat-window). Select **Continue in chat window...** to maintain a record and context of the conversation, and continue in the chat window.
121+
122+
:::image type="content" source="media/vs-2022/copilot-chat-context/promote-inline-chat-to-chat-window.png" alt-text="Screenshot of promoting ongoing thread in inline chat to the chat window.":::
123+
97124
## Next steps
98125

99126
- [GitHub Copilot extension for Visual Studio](visual-studio-github-copilot-extension.md)
Loading
Loading
Loading

0 commit comments

Comments
 (0)