Skip to content

Commit 86c26c1

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools into dev/garretts/instrumentation
2 parents b147b2b + 5d32121 commit 86c26c1

File tree

10 files changed

+171
-73
lines changed

10 files changed

+171
-73
lines changed

Extension/.scripts/common.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const Git = async (...args: Parameters<Awaited<CommandFunction>>) => (awa
4848
export const GitClean = async (...args: Parameters<Awaited<CommandFunction>>) => (await new Command(await git, 'clean'))(...args);
4949

5050
export async function getModifiedIgnoredFiles() {
51-
const {code, error, stdio } = await GitClean('-Xd', '-n');
51+
const { code, error, stdio } = await GitClean('-Xd', '-n');
5252
if (code) {
5353
throw new Error(`\n${error.all().join('\n')}`);
5454
}
@@ -65,11 +65,11 @@ export async function rimraf(...paths: string[]) {
6565
}
6666
if (await filepath.isFolder(each)) {
6767
verbose(`Removing folder ${red(each)}`);
68-
all.push(rm(each, {recursive: true, force: true}));
68+
all.push(rm(each, { recursive: true, force: true }));
6969
continue;
7070
}
7171
verbose(`Removing file ${red(each)}`);
72-
all.push(rm(each, {force: true}));
72+
all.push(rm(each, { force: true }));
7373
}
7474
await Promise.all(all);
7575
}
@@ -345,3 +345,15 @@ export async function checkBinaries() {
345345
}
346346
return failing;
347347
}
348+
349+
export async function checkProposals() {
350+
let failing = false;
351+
352+
await rm(`${$root}/vscode.proposed.chatParticipantAdditions.d.ts`);
353+
failing = await assertAnyFile('vscode.proposed.chatParticipantAdditions.d.ts') && (quiet || warn(`The VSCode import file '${$root}/vscode.proposed.chatParticipantAdditions.d.ts' should not be present.`)) || failing;
354+
355+
if (!failing) {
356+
verbose('VSCode proposals appear to be in place.');
357+
}
358+
return failing;
359+
}

Extension/.scripts/verify.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See 'LICENSE' in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55

6-
import { checkBinaries, checkCompiled, checkDTS, checkPrep, error, green } from './common';
6+
import { checkBinaries, checkCompiled, checkDTS, checkPrep, checkProposals, error, green } from './common';
77
const quiet = process.argv.includes('--quiet');
88

99
export async function main() {
@@ -50,3 +50,12 @@ export async function dts() {
5050
process.exit(1);
5151
}
5252
}
53+
54+
export async function proposals() {
55+
let failing = false;
56+
failing = (await checkProposals() && (quiet || error(`Issue with VSCode proposals. Run ${green('yarn prep')} to fix it.`))) || failing;
57+
58+
if (failing) {
59+
process.exit(1);
60+
}
61+
}

Extension/CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# C/C++ for Visual Studio Code Changelog
22

3-
## Version 1.23.3: January 9, 2025
4-
### New Feature
5-
* Enable setting multiple compile commands. [#7029](https://github.com/microsoft/vscode-cpptools/issues/7029)
6-
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12960](https://github.com/microsoft/vscode-cpptools/pull/12960)
3+
## Version 1.23.4: January 16, 2025
4+
### Bug Fixes
5+
* Fix a couple bugs with `.editorConfig` handling. [PR #13140](https://github.com/microsoft/vscode-cpptools/pull/13140)
6+
* Fix a bug when processing a file with invalid multi-byte sequences. [#13150](https://github.com/microsoft/vscode-cpptools/issues/13150)
7+
* Fix a potential telemetry issue with Copilot hover. [PR #13158](https://github.com/microsoft/vscode-cpptools/pull/13158)
8+
* Fix a crash when Copilot hover is used on code with no definition file (e.g. literals).
9+
* Update clang-format and clang-tidy from 19.1.6 to 19.1.7.
10+
* Update vsdbg from 17.12.10729.1 to 17.13.20115.1.
11+
* Fix `libiconv.dll` not being signed on Windows.
712

13+
## Version 1.23.3: January 9, 2025
814
### Enhancements
915
* Modifications to the snippet completions to more closely match the snippets provided by TypeScript. [#4482](https://github.com/microsoft/vscode-cpptools/issues/4482)
16+
* Enable setting multiple compile commands. [#7029](https://github.com/microsoft/vscode-cpptools/issues/7029)
17+
* Thank you for the contribution. [@yiftahw](https://github.com/yiftahw) [PR #12960](https://github.com/microsoft/vscode-cpptools/pull/12960)
1018
* Update clang path setting descriptions. [PR #13071](https://github.com/microsoft/vscode-cpptools/pull/13071)
1119
* Update clang-format and clang-tidy from 19.1.5 to 19.1.6.
1220
* IntelliSense parser updates.

Extension/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "1.23.3-main",
5+
"version": "1.23.4-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -38,7 +38,8 @@
3838
"Snippets"
3939
],
4040
"enabledApiProposals": [
41-
"terminalDataWriteEvent"
41+
"terminalDataWriteEvent",
42+
"chatParticipantAdditions"
4243
],
4344
"capabilities": {
4445
"untrustedWorkspaces": {
@@ -6537,7 +6538,7 @@
65376538
"translations-generate": "set NODE_OPTIONS=--no-experimental-fetch && gulp translations-generate",
65386539
"translations-import": "gulp translations-import",
65396540
"import-edge-strings": "ts-node -T ./.scripts/import_edge_strings.ts",
6540-
"prep:dts": "yarn verify dts --quiet || (npx @vscode/dts dev && npx @vscode/dts main)",
6541+
"prep:dts": "yarn verify dts --quiet || (npx @vscode/dts main && npx @vscode/dts dev && yarn verify proposals)",
65416542
"build": "yarn prep:dts && echo [Building TypeScript code] && tsc --build tsconfig.json"
65426543
},
65436544
"devDependencies": {

Extension/src/LanguageServer/Providers/CopilotHoverProvider.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import * as vscode from 'vscode';
66
import { Position, ResponseError } from 'vscode-languageclient';
77
import * as nls from 'vscode-nls';
8-
import { DefaultClient, GetCopilotHoverInfoParams, GetCopilotHoverInfoRequest } from '../client';
8+
import { DefaultClient, GetCopilotHoverInfoParams, GetCopilotHoverInfoRequest, GetCopilotHoverInfoResult } from '../client';
99
import { RequestCancelled, ServerCancelled } from '../protocolFilter';
1010
import { CppSettings } from '../settings';
1111

@@ -92,8 +92,8 @@ export class CopilotHoverProvider implements vscode.HoverProvider {
9292
return this.currentCancellationToken;
9393
}
9494

95-
public async getRequestInfo(document: vscode.TextDocument, position: vscode.Position): Promise<string> {
96-
let requestInfo = "";
95+
public async getRequestInfo(document: vscode.TextDocument, position: vscode.Position): Promise<GetCopilotHoverInfoResult> {
96+
let response: GetCopilotHoverInfoResult;
9797
const params: GetCopilotHoverInfoParams = {
9898
textDocument: { uri: document.uri.toString() },
9999
position: Position.create(position.line, position.character)
@@ -105,16 +105,15 @@ export class CopilotHoverProvider implements vscode.HoverProvider {
105105
}
106106

107107
try {
108-
const response = await this.client.languageClient.sendRequest(GetCopilotHoverInfoRequest, params, this.currentCancellationToken);
109-
requestInfo = response.content;
108+
response = await this.client.languageClient.sendRequest(GetCopilotHoverInfoRequest, params, this.currentCancellationToken);
110109
} catch (e: any) {
111110
if (e instanceof ResponseError && (e.code === RequestCancelled || e.code === ServerCancelled)) {
112111
throw new vscode.CancellationError();
113112
}
114113
throw e;
115114
}
116115

117-
return requestInfo;
116+
return response;
118117
}
119118

120119
public isCancelled(document: vscode.TextDocument, position: vscode.Position): boolean {

Extension/src/LanguageServer/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,9 @@ export interface GetCopilotHoverInfoParams {
541541
position: Position;
542542
}
543543

544-
interface GetCopilotHoverInfoResult {
544+
export interface GetCopilotHoverInfoResult {
545545
content: string;
546+
files: string[];
546547
}
547548

548549
export interface ChatContextResult {

Extension/src/LanguageServer/copilotProviders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function registerRelatedFilesProvider(): Promise<void> {
4848
try {
4949
const getIncludesHandler = async () => (await getIncludes(uri, 1))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [];
5050
const getTraitsHandler = async () => {
51-
const projectContext = await getProjectContext(uri, context);
51+
const projectContext = await getProjectContext(uri, context, telemetryProperties, telemetryMetrics);
5252

5353
if (!projectContext) {
5454
return undefined;

Extension/src/LanguageServer/extension.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as StreamZip from 'node-stream-zip';
1111
import * as os from 'os';
1212
import * as path from 'path';
1313
import * as vscode from 'vscode';
14-
import { Range } from 'vscode-languageclient';
14+
import { CancellationToken, Range } from 'vscode-languageclient';
1515
import * as nls from 'vscode-nls';
1616
import { TargetPopulation } from 'vscode-tas-client';
1717
import * as which from 'which';
@@ -1428,18 +1428,34 @@ async function onCopilotHover(): Promise<void> {
14281428

14291429
// Gather the content for the query from the client.
14301430
const requestInfo = await copilotHoverProvider.getRequestInfo(hoverDocument, hoverPosition);
1431-
if (requestInfo.length === 0) {
1431+
try {
1432+
for (const file of requestInfo.files) {
1433+
const fileUri = vscode.Uri.file(file);
1434+
if (await vscodelm.fileIsIgnored(fileUri, copilotHoverProvider.getCurrentHoverCancellationToken() ?? CancellationToken.None)) {
1435+
telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available due to content exclusion." });
1436+
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available.") + "\n\n" +
1437+
localize("copilot.hover.excluded", "The file containing this symbol's definition or declaration has been excluded from use with Copilot."));
1438+
return;
1439+
}
1440+
}
1441+
} catch (err) {
1442+
if (err instanceof Error) {
1443+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.name);
1444+
}
1445+
return;
1446+
}
1447+
if (requestInfo.content.length === 0) {
14321448
// Context is not available for this symbol.
14331449
telemetry.logLanguageServerEvent("CopilotHover", { "Message": "Copilot summary is not available for this symbol." });
1434-
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable", "Copilot summary is not available for this symbol."));
1450+
await showCopilotContent(copilotHoverProvider, hoverDocument, hoverPosition, localize("copilot.hover.unavailable.symbol", "Copilot summary is not available for this symbol."));
14351451
return;
14361452
}
14371453

14381454
const locale = getLocaleId();
14391455

14401456
const messages = [
14411457
vscode.LanguageModelChatMessage
1442-
.User(requestInfo + locale)];
1458+
.User(requestInfo.content + locale)];
14431459

14441460
const [model] = await vscodelm.selectChatModels(modelSelector);
14451461

@@ -1453,7 +1469,7 @@ async function onCopilotHover(): Promise<void> {
14531469
} catch (err) {
14541470
if (err instanceof vscode.LanguageModelError) {
14551471
console.log(err.message, err.code, err.cause);
1456-
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.message);
1472+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.code);
14571473
} else {
14581474
throw err;
14591475
}
@@ -1473,9 +1489,12 @@ async function onCopilotHover(): Promise<void> {
14731489
content += fragment;
14741490
}
14751491
} catch (err) {
1476-
if (err instanceof Error) {
1492+
if (err instanceof vscode.LanguageModelError) {
1493+
console.log(err.message, err.code, err.cause);
1494+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.code);
1495+
} else if (err instanceof Error) {
14771496
console.log(err.message, err.cause);
1478-
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.message);
1497+
await reportCopilotFailure(copilotHoverProvider, hoverDocument, hoverPosition, err.name);
14791498
}
14801499
return;
14811500
}

Extension/src/LanguageServer/lmTool.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,20 @@ function filterCompilerArguments(compiler: string, compilerArguments: string[],
124124
if (filteredCompilerArguments.length > 0) {
125125
// Telemetry to learn about the argument distribution. The filtered arguments are expected to be non-PII.
126126
telemetryProperties["filteredCompilerArguments"] = filteredCompilerArguments.join(',');
127-
telemetryProperties["filters"] = Object.keys(filterMap).filter(filter => !!filter).join(',');
127+
}
128+
129+
const filters = Object.keys(filterMap).filter(filter => !!filter).join(',');
130+
if (filters) {
131+
telemetryProperties["filters"] = filters;
128132
}
129133

130134
return result;
131135
}
132136

133-
export async function getProjectContext(uri: vscode.Uri, context: { flags: Record<string, unknown> }): Promise<ProjectContext | undefined> {
134-
const telemetryProperties: Record<string, string> = {};
135-
const telemetryMetrics: Record<string, number> = {};
137+
export async function getProjectContext(uri: vscode.Uri, context: { flags: Record<string, unknown> }, telemetryProperties: Record<string, string>, telemetryMetrics: Record<string, number>): Promise<ProjectContext | undefined> {
136138
try {
137139
const projectContext = await checkDuration<ProjectContextResult | undefined>(async () => await getClients()?.ActiveClient?.getProjectContext(uri) ?? undefined);
138-
telemetryMetrics["duration"] = projectContext.duration;
140+
telemetryMetrics["projectContextDuration"] = projectContext.duration;
139141
if (!projectContext.result) {
140142
return undefined;
141143
}
@@ -186,10 +188,8 @@ export async function getProjectContext(uri: vscode.Uri, context: { flags: Recor
186188
catch {
187189
// Intentionally swallow any exception.
188190
}
189-
telemetryProperties["error"] = "true";
191+
telemetryProperties["projectContextError"] = "true";
190192
throw exception; // Throw the exception for auto-retry.
191-
} finally {
192-
telemetry.logCopilotEvent('ProjectContext', telemetryProperties, telemetryMetrics);
193193
}
194194
}
195195

0 commit comments

Comments
 (0)