✨ vscode context menus

This commit is contained in:
Nate Sesti 2023-11-04 11:43:13 -07:00
parent a5444022ef
commit 94ab3dbbb6
5 changed files with 104 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -100,15 +100,30 @@
"category": "Continue",
"title": "Toggle Right Sidebar"
},
{
"command": "continue.focusContinueInput",
"category": "Continue",
"title": "Add Highlighted Code to Context"
},
{
"command": "continue.focusContinueInputWithEdit",
"category": "Continue",
"title": "Focus Continue Input With Edit"
"title": "Edit Highlighted Code"
},
{
"command": "continue.debugTerminal",
"category": "Continue",
"title": "Debug Terminal"
},
{
"command": "continue.shareSession",
"category": "Continue",
"title": "Share Session"
},
{
"command": "continue.selectFilesAsContext",
"category": "Continue",
"title": "Continue: Select Files as Context"
}
],
"keybindings": [
@ -148,8 +163,50 @@
"key": "ctrl+shift+r"
}
],
"submenus": [
{
"id": "continue.continueSubMenu",
"label": "Continue"
}
],
"menus": {
"view/title": []
"terminal/context": [
{
"command": "continue.debugTerminal",
"group": "1_debug@1"
}
],
"webview/context": [
{
"command": "continue.shareSession",
"group": "navigation@1"
}
],
"editor/context": [
{
"submenu": "continue.continueSubMenu",
"group": "1_debug@1",
"when": "editorHasSelection"
}
],
"continue.continueSubMenu": [
{
"command": "continue.focusContinueInput",
"when": "editorHasSelection",
"group": "Continue"
},
{
"command": "continue.focusContinueInputWithEdit",
"group": "Continue",
"when": "editorHasSelection"
}
],
"explorer/context": [
{
"command": "continue.selectFilesAsContext",
"group": "1_debug@1"
}
]
},
"viewsContainers": {
"activitybar": [

View file

@ -40,6 +40,33 @@ function addHighlightedCodeToContext(edit: boolean) {
}
}
async function addEntireFileToContext(filepath: vscode.Uri, edit: boolean) {
focusedOnContinueInput = !focusedOnContinueInput;
// Get the contents of the file
const contents = (await vscode.workspace.fs.readFile(filepath)).toString();
const rangeInFileWithContents = {
filepath: filepath.fsPath,
contents: contents,
range: {
start: {
line: 0,
character: 0,
},
end: {
line: contents.split(os.EOL).length - 1,
character: 0,
},
},
};
debugPanelWebview?.postMessage({
type: "highlightedCode",
rangeInFileWithContents,
edit,
});
}
export const setFocusedOnContinueInput = (value: boolean) => {
focusedOnContinueInput = value;
};
@ -130,6 +157,9 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
"continue.sendMainUserInput": (text: string) => {
ideProtocolClient.sendMainUserInput(text);
},
"continue.shareSession": () => {
ideProtocolClient.sendMainUserInput("/share");
},
"continue.selectRange": (startLine: number, endLine: number) => {
if (!vscode.window.activeTextEditor) {
return;
@ -155,6 +185,16 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
"continue.sendToTerminal": (text: string) => {
ideProtocolClient.runCommand(text);
},
"continue.selectFilesAsContext": (
firstUri: vscode.Uri,
uris: vscode.Uri[]
) => {
vscode.commands.executeCommand("continue.continueGUIView.focus");
for (const uri of uris) {
addEntireFileToContext(uri, false);
}
},
};
export function registerAllCommands(context: vscode.ExtensionContext) {

View file

@ -205,7 +205,7 @@ const DeleteButtonDiv = styled.div`
right: 12px;
background-color: ${secondaryDark};
border-radius: ${defaultBorderRadius};
z-index: 100;
z-index: 50;
`;
const DynamicQueryTitleDiv = styled.div`