|
5 | 5 |
|
6 | 6 | import * as vscode from 'vscode'; |
7 | 7 | import { MAX_LINE_LENGTH } from './util'; |
8 | | -import { CREATE_ISSUE_TRIGGERS, ISSUES_SETTINGS_NAMESPACE } from '../common/settingKeys'; |
| 8 | +import { CODING_AGENT, CREATE_ISSUE_TRIGGERS, ISSUES_SETTINGS_NAMESPACE, SHOW_CODE_LENS } from '../common/settingKeys'; |
9 | 9 | import { escapeRegExp } from '../common/utils'; |
10 | 10 | import { CopilotRemoteAgentManager } from '../github/copilotRemoteAgent'; |
11 | 11 | import { ISSUE_OR_URL_EXPRESSION } from '../github/utils'; |
@@ -98,32 +98,28 @@ export class IssueTodoProvider implements vscode.CodeActionProvider, vscode.Code |
98 | 98 | return codeActions; |
99 | 99 | } |
100 | 100 |
|
101 | | - provideCodeLenses( |
| 101 | + async provideCodeLenses( |
102 | 102 | document: vscode.TextDocument, |
103 | 103 | _token: vscode.CancellationToken, |
104 | | - ): vscode.CodeLens[] { |
| 104 | + ): Promise<vscode.CodeLens[]> { |
105 | 105 | if (this.expression === undefined) { |
106 | 106 | return []; |
107 | 107 | } |
108 | 108 |
|
| 109 | + // Check if CodeLens is enabled |
| 110 | + const isCodeLensEnabled = vscode.workspace.getConfiguration(CODING_AGENT).get(SHOW_CODE_LENS, true); |
| 111 | + if (!isCodeLensEnabled) { |
| 112 | + return []; |
| 113 | + } |
| 114 | + |
109 | 115 | const codeLenses: vscode.CodeLens[] = []; |
110 | 116 | for (let lineNumber = 0; lineNumber < document.lineCount; lineNumber++) { |
111 | 117 | const line = document.lineAt(lineNumber).text; |
112 | 118 | const todoInfo = this.findTodoInLine(lineNumber, line); |
113 | 119 | if (todoInfo) { |
114 | 120 | const { match, search, insertIndex } = todoInfo; |
115 | 121 | const range = new vscode.Range(lineNumber, search, lineNumber, search + match[0].length); |
116 | | - |
117 | | - // Create GitHub Issue CodeLens |
118 | | - const createIssueCodeLens = new vscode.CodeLens(range, { |
119 | | - title: vscode.l10n.t('Create GitHub Issue'), |
120 | | - command: 'issue.createIssueFromSelection', |
121 | | - arguments: [{ document, lineNumber, line, insertIndex, range }], |
122 | | - }); |
123 | | - codeLenses.push(createIssueCodeLens); |
124 | | - |
125 | | - // Delegate to coding agent CodeLens (if copilot manager is available) |
126 | | - if (this.copilotRemoteAgentManager) { |
| 122 | + if (this.copilotRemoteAgentManager && (await this.copilotRemoteAgentManager.isAvailable())) { |
127 | 123 | const startAgentCodeLens = new vscode.CodeLens(range, { |
128 | 124 | title: vscode.l10n.t('Delegate to coding agent'), |
129 | 125 | command: 'issue.startCodingAgentFromTodo', |
|
0 commit comments