Skip to content

Commit 3ef2ac9

Browse files
committed
resolved merge conflict
2 parents 0ef1abd + 105bc3c commit 3ef2ac9

20 files changed

+537
-372
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"engines": {
1313
"vscode": "^1.84.0",
14-
"node": ">=20.18.1"
14+
"node": "20.18.1"
1515
},
1616
"author": {
1717
"name": "Roo Code"
@@ -185,19 +185,19 @@
185185
],
186186
"roo-code.contextMenu": [
187187
{
188-
"command": "roo-cline.explainCode",
188+
"command": "roo-cline.addToContext",
189189
"group": "1_actions@1"
190190
},
191191
{
192-
"command": "roo-cline.fixCode",
192+
"command": "roo-cline.explainCode",
193193
"group": "1_actions@2"
194194
},
195195
{
196-
"command": "roo-cline.improveCode",
196+
"command": "roo-cline.fixCode",
197197
"group": "1_actions@3"
198198
},
199199
{
200-
"command": "roo-cline.addToContext",
200+
"command": "roo-cline.improveCode",
201201
"group": "1_actions@4"
202202
}
203203
],

src/activate/registerCodeActions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,24 @@ const registerCodeAction = (
5353
// Handle both code action and direct command cases.
5454
let filePath: string
5555
let selectedText: string
56+
let startLine: number | undefined
57+
let endLine: number | undefined
5658
let diagnostics: any[] | undefined
5759

5860
if (args.length > 1) {
5961
// Called from code action.
60-
;[filePath, selectedText, diagnostics] = args
62+
;[filePath, selectedText, startLine, endLine, diagnostics] = args
6163
} else {
6264
// Called directly from command palette.
6365
const context = EditorUtils.getEditorContext()
6466
if (!context) return
65-
;({ filePath, selectedText, diagnostics } = context)
67+
;({ filePath, selectedText, startLine, endLine, diagnostics } = context)
6668
}
6769

6870
const params = {
6971
...{ filePath, selectedText },
72+
...(startLine !== undefined ? { startLine: startLine.toString() } : {}),
73+
...(endLine !== undefined ? { endLine: endLine.toString() } : {}),
7074
...(diagnostics ? { diagnostics } : {}),
7175
...(userInput ? { userInput } : {}),
7276
}

src/core/Cline.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
} from "../integrations/misc/extract-text"
3131
import { countFileLines } from "../integrations/misc/line-counter"
3232
import { fetchInstructionsTool } from "./tools/fetchInstructionsTool"
33+
import { readFileTool } from "./tools/readFileTool"
3334
import { ExitCodeDetails } from "../integrations/terminal/TerminalProcess"
3435
import { Terminal } from "../integrations/terminal/Terminal"
3536
import { TerminalRegistry } from "../integrations/terminal/TerminalRegistry"
@@ -88,9 +89,7 @@ import { insertGroups } from "./diff/insert-groups"
8889
import { telemetryService } from "../services/telemetry/TelemetryService"
8990
import { validateToolUse, isToolAllowedForMode, ToolName } from "./mode-validator"
9091
import { parseXml } from "../utils/xml"
91-
import { readLines } from "../integrations/misc/read-lines"
9292
import { getWorkspacePath } from "../utils/path"
93-
import { isBinaryFile } from "isbinaryfile"
9493
import { ToolUseHandlerFactory } from "./tool-handlers/ToolUseHandlerFactory" //Import the factory
9594

9695
export type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>

src/core/CodeActionProvider.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,26 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
5656
const filePath = EditorUtils.getFilePath(document)
5757
const actions: vscode.CodeAction[] = []
5858

59+
actions.push(
60+
this.createAction(
61+
ACTION_NAMES.ADD_TO_CONTEXT,
62+
vscode.CodeActionKind.QuickFix,
63+
COMMAND_IDS.ADD_TO_CONTEXT,
64+
[
65+
filePath,
66+
effectiveRange.text,
67+
effectiveRange.range.start.line + 1,
68+
effectiveRange.range.end.line + 1,
69+
],
70+
),
71+
)
72+
5973
actions.push(
6074
...this.createActionPair(ACTION_NAMES.EXPLAIN, vscode.CodeActionKind.QuickFix, COMMAND_IDS.EXPLAIN, [
6175
filePath,
6276
effectiveRange.text,
77+
effectiveRange.range.start.line + 1,
78+
effectiveRange.range.end.line + 1,
6379
]),
6480
)
6581

@@ -74,6 +90,8 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
7490
...this.createActionPair(ACTION_NAMES.FIX, vscode.CodeActionKind.QuickFix, COMMAND_IDS.FIX, [
7591
filePath,
7692
effectiveRange.text,
93+
effectiveRange.range.start.line + 1,
94+
effectiveRange.range.end.line + 1,
7795
diagnosticMessages,
7896
]),
7997
)
@@ -83,6 +101,8 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
83101
...this.createActionPair(ACTION_NAMES.FIX_LOGIC, vscode.CodeActionKind.QuickFix, COMMAND_IDS.FIX, [
84102
filePath,
85103
effectiveRange.text,
104+
effectiveRange.range.start.line + 1,
105+
effectiveRange.range.end.line + 1,
86106
]),
87107
)
88108
}
@@ -92,16 +112,12 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
92112
ACTION_NAMES.IMPROVE,
93113
vscode.CodeActionKind.RefactorRewrite,
94114
COMMAND_IDS.IMPROVE,
95-
[filePath, effectiveRange.text],
96-
),
97-
)
98-
99-
actions.push(
100-
this.createAction(
101-
ACTION_NAMES.ADD_TO_CONTEXT,
102-
vscode.CodeActionKind.QuickFix,
103-
COMMAND_IDS.ADD_TO_CONTEXT,
104-
[filePath, effectiveRange.text],
115+
[
116+
filePath,
117+
effectiveRange.text,
118+
effectiveRange.range.start.line + 1,
119+
effectiveRange.range.end.line + 1,
120+
],
105121
),
106122
)
107123

src/core/EditorUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export interface EditorContext {
3838
filePath: string
3939
/** The effective text selected or derived from the document. */
4040
selectedText: string
41+
/** The starting line number of the selected text (1-based). */
42+
startLine: number
43+
/** The ending line number of the selected text (1-based). */
44+
endLine: number
4145
/** Optional list of diagnostics associated with the effective range. */
4246
diagnostics?: DiagnosticData[]
4347
}
@@ -194,6 +198,8 @@ export class EditorUtils {
194198
return {
195199
filePath,
196200
selectedText: effectiveRange.text,
201+
startLine: effectiveRange.range.start.line + 1, // Convert to 1-based line numbers
202+
endLine: effectiveRange.range.end.line + 1, // Convert to 1-based line numbers
197203
...(diagnostics.length > 0 ? { diagnostics } : {}),
198204
}
199205
} catch (error) {

src/core/__tests__/CodeActionProvider.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ describe("CodeActionProvider", () => {
7575
const actions = provider.provideCodeActions(mockDocument, mockRange, mockContext)
7676

7777
expect(actions).toHaveLength(7) // 2 explain + 2 fix logic + 2 improve + 1 add to context
78-
expect((actions as any)[0].title).toBe(`${ACTION_NAMES.EXPLAIN} in New Task`)
79-
expect((actions as any)[1].title).toBe(`${ACTION_NAMES.EXPLAIN} in Current Task`)
80-
expect((actions as any)[2].title).toBe(`${ACTION_NAMES.FIX_LOGIC} in New Task`)
81-
expect((actions as any)[3].title).toBe(`${ACTION_NAMES.FIX_LOGIC} in Current Task`)
82-
expect((actions as any)[4].title).toBe(`${ACTION_NAMES.IMPROVE} in New Task`)
83-
expect((actions as any)[5].title).toBe(`${ACTION_NAMES.IMPROVE} in Current Task`)
84-
expect((actions as any)[6].title).toBe(ACTION_NAMES.ADD_TO_CONTEXT)
78+
expect((actions as any)[0].title).toBe(ACTION_NAMES.ADD_TO_CONTEXT)
79+
expect((actions as any)[1].title).toBe(`${ACTION_NAMES.EXPLAIN} in New Task`)
80+
expect((actions as any)[2].title).toBe(`${ACTION_NAMES.EXPLAIN} in Current Task`)
81+
expect((actions as any)[3].title).toBe(`${ACTION_NAMES.FIX_LOGIC} in New Task`)
82+
expect((actions as any)[4].title).toBe(`${ACTION_NAMES.FIX_LOGIC} in Current Task`)
83+
expect((actions as any)[5].title).toBe(`${ACTION_NAMES.IMPROVE} in New Task`)
84+
expect((actions as any)[6].title).toBe(`${ACTION_NAMES.IMPROVE} in Current Task`)
8585
})
8686

8787
it("should provide fix action instead of fix logic when diagnostics exist", () => {

0 commit comments

Comments
 (0)