forked from continuedev/continue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiffContextProvider.ts
More file actions
34 lines (31 loc) · 837 Bytes
/
DiffContextProvider.ts
File metadata and controls
34 lines (31 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { BaseContextProvider } from "../index.js";
class DiffContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
title: "diff",
displayTitle: "Git Diff",
description: "Reference the current git diff",
type: "normal",
};
async getContextItems(
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const diff = await extras.ide.getDiff();
return [
{
description: "The current git diff",
content:
diff.trim() === ""
? "Git shows no current changes."
: `\`\`\`git diff\n${diff}\n\`\`\``,
name: "Git Diff",
},
];
}
}
export default DiffContextProvider;