Skip to content

Commit 9d28ba1

Browse files
authored
Prevent vcpkg code action from appearing in all unrelated code action menus (#11280)
* prevent vcpkg code action from appearing * resolve PR * resolve PR
1 parent 514e608 commit 9d28ba1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export async function activate(): Promise<void> {
228228
];
229229
codeActionProvider = vscode.languages.registerCodeActionsProvider(selector, {
230230
provideCodeActions: async (document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext): Promise<vscode.CodeAction[]> => {
231+
231232
if (!await clients.ActiveClient.getVcpkgEnabled()) {
232233
return [];
233234
}
@@ -237,13 +238,17 @@ export async function activate(): Promise<void> {
237238
return [];
238239
}
239240

241+
const ports: string[] = await lookupIncludeInVcpkg(document, range.start.line);
242+
if (ports.length <= 0) {
243+
return [];
244+
}
245+
240246
telemetry.logLanguageServerEvent('codeActionsProvided', { "source": "vcpkg" });
241247

242248
if (!await clients.ActiveClient.getVcpkgInstalled()) {
243249
return [getVcpkgHelpAction()];
244250
}
245251

246-
const ports: string[] = await lookupIncludeInVcpkg(document, range.start.line);
247252
const actions: vscode.CodeAction[] = ports.map<vscode.CodeAction>(getVcpkgClipboardInstallAction);
248253
return actions;
249254
}

0 commit comments

Comments
 (0)