Skip to content

Commit 3e853dd

Browse files
committed
feat: add keyboard shortcut for "Add to Context" action
- Add Cmd+apostrophe (macOS) / Ctrl+apostrophe (Windows/Linux) keyboard shortcut - Shortcut adds selected code to context and focuses input field - Only active when editor has text selection - Addresses issue #7907 for improved keyboard workflow
1 parent 8fee312 commit 3e853dd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/activate/registerCodeActions.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const registerCodeAction = (context: vscode.ExtensionContext, command: CodeActio
2929
// Called from code action.
3030
;[filePath, selectedText, startLine, endLine, diagnostics] = args
3131
} else {
32-
// Called directly from command palette.
32+
// Called directly from command palette or keyboard shortcut.
3333
const context = EditorUtils.getEditorContext()
3434

3535
if (!context) {
@@ -48,6 +48,23 @@ const registerCodeAction = (context: vscode.ExtensionContext, command: CodeActio
4848
}
4949

5050
await ClineProvider.handleCodeAction(command, promptType, params)
51+
52+
// If this is the addToContext command, also focus the input field
53+
if (command === "addToContext") {
54+
// Focus the Roo Code sidebar/panel
55+
const visibleProvider = ClineProvider.getVisibleInstance()
56+
if (!visibleProvider) {
57+
// If no visible provider, try to show the sidebar view
58+
await vscode.commands.executeCommand("roo-cline.SidebarProvider.focus")
59+
}
60+
// Send focus input message after a short delay to ensure the view is ready
61+
setTimeout(async () => {
62+
const provider = ClineProvider.getVisibleInstance()
63+
if (provider) {
64+
await provider.postMessageToWebview({ type: "action", action: "focusInput" })
65+
}
66+
}, 100)
67+
}
5168
}),
5269
)
5370
}

src/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@
302302
}
303303
]
304304
},
305+
"keybindings": [
306+
{
307+
"command": "roo-cline.addToContext",
308+
"key": "cmd+'",
309+
"mac": "cmd+'",
310+
"win": "ctrl+'",
311+
"linux": "ctrl+'",
312+
"when": "editorTextFocus && editorHasSelection"
313+
}
314+
],
305315
"submenus": [
306316
{
307317
"id": "roo-cline.contextMenu",

0 commit comments

Comments
 (0)