mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: add 'Add To Context' code action
- Add new command registration and menu item - Add new code action type and command ID - Add support prompt config for adding code to context - Add message handling in webview for setting chat box content - Add logic to append selected code to existing chat input
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import * as vscode from "vscode"
|
||||
import { ClineProvider } from "./webview/ClineProvider"
|
||||
import { EditorUtils } from "./EditorUtils"
|
||||
|
||||
export const ACTION_NAMES = {
|
||||
EXPLAIN: "Roo Code: Explain Code",
|
||||
FIX: "Roo Code: Fix Code",
|
||||
FIX_LOGIC: "Roo Code: Fix Logic",
|
||||
IMPROVE: "Roo Code: Improve Code",
|
||||
ADD_TO_CONTEXT: "Roo Code: Add to Context",
|
||||
} as const
|
||||
|
||||
const COMMAND_IDS = {
|
||||
EXPLAIN: "roo-cline.explainCode",
|
||||
FIX: "roo-cline.fixCode",
|
||||
IMPROVE: "roo-cline.improveCode",
|
||||
ADD_TO_CONTEXT: "roo-cline.addToContext",
|
||||
} as const
|
||||
|
||||
export class CodeActionProvider implements vscode.CodeActionProvider {
|
||||
@@ -74,6 +76,13 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
||||
]),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
actions.push(
|
||||
...this.createActionPair(ACTION_NAMES.FIX_LOGIC, vscode.CodeActionKind.QuickFix, COMMAND_IDS.FIX, [
|
||||
filePath,
|
||||
effectiveRange.text,
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
actions.push(
|
||||
@@ -85,6 +94,15 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
||||
),
|
||||
)
|
||||
|
||||
actions.push(
|
||||
this.createAction(
|
||||
ACTION_NAMES.ADD_TO_CONTEXT,
|
||||
vscode.CodeActionKind.QuickFix,
|
||||
COMMAND_IDS.ADD_TO_CONTEXT,
|
||||
[filePath, effectiveRange.text],
|
||||
),
|
||||
)
|
||||
|
||||
return actions
|
||||
} catch (error) {
|
||||
console.error("Error providing code actions:", error)
|
||||
|
||||
Reference in New Issue
Block a user