Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ export class AutocompleteCodeActionProvider implements vscode.CodeActionProvider
quickfix: vscode.CodeActionKind.QuickFix,
}

private _enabled = false

public set enabled(value: boolean) {
this._enabled = value
}

public provideCodeActions(
document: vscode.TextDocument,
range: vscode.Range | vscode.Selection,
_context: vscode.CodeActionContext,
_token: vscode.CancellationToken,
): vscode.ProviderResult<(vscode.CodeAction | vscode.Command)[]> {
if (!this._enabled) return []

const action = new vscode.CodeAction(
t("kilocode:autocomplete.codeAction.title"),
this.providedCodeActionKinds["quickfix"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class AutocompleteServiceManager {
public async load() {
this.settings = readSettings()

this.codeActionProvider.enabled = this.settings?.enableSmartInlineTaskKeybinding ?? false
await this.updateGlobalContext()
this.updateStatusBar()
await this.ensureInlineCompletionProviderRegistration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class KiloCodeActionProvider implements vscode.CodeActionProvider {
if (hasDiagnostics) {
const fix = new vscode.CodeAction("Fix with Kilo Code", vscode.CodeActionKind.QuickFix)
fix.command = { command: "kilo-code.new.fixCode", title: "Fix with Kilo Code" }
fix.isPreferred = true
actions.push(fix)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/kilo-vscode/tests/unit/code-action-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ describe("KiloCodeActionProvider", () => {
expect(result).toHaveLength(2)
})

it("Fix action is preferred", () => {
it("Fix action is not preferred so it does not hijack auto-fix", () => {
const result = provider.provideCodeActions({} as never, makeRange(false) as never, makeContext(1) as never)
const fix = result.find((a) => a.title === "Fix with Kilo Code")
expect(fix?.isPreferred).toBe(true)
expect(fix?.isPreferred).toBeFalsy()
})

it("Fix action uses QuickFix kind", () => {
Expand Down
Loading