diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 71a2ad23eb..8891897fa2 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,10 @@ # C/C++ for Visual Studio Code Changelog +## Version 1.22.10: October 21, 2024 +### Bug Fixes +* Fix the 'Extract to Function' feature not working. +* Fix the 'Go to Next/Prev Preprocessor Conditional' feature not working. + ## Version 1.22.9: October 10, 2024 ### Performance Improvements * Initialization performance improvements. [#12030](https://github.com/microsoft/vscode-cpptools/issues/12030) diff --git a/Extension/package.json b/Extension/package.json index 2fbbcbb167..f5eb73a424 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -38,8 +38,7 @@ "Snippets" ], "enabledApiProposals": [ - "terminalDataWriteEvent", - "lmTools" + "terminalDataWriteEvent" ], "capabilities": { "untrustedWorkspaces": { @@ -6519,10 +6518,7 @@ "userDescription": "%c_cpp.languageModelTools.configuration.userDescription%", "modelDescription": "For the active C or C++ file, this tool provides: the language (C, C++, or CUDA), the language standard version (such as C++11, C++14, C++17, or C++20), the compiler (such as GCC, Clang, or MSVC), the target platform (such as x86, x64, or ARM), and the target architecture (such as 32-bit or 64-bit).", "icon": "$(file-code)", - "when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)", - "supportedContentTypes": [ - "text/plain" - ] + "when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)" } ] }, diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index 04dcaba701..7d4d81d5ad 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -2387,7 +2387,9 @@ export class DefaultClient implements Client { } this.updateInactiveRegions(intelliSenseResult.uri, intelliSenseResult.inactiveRegions, intelliSenseResult.clearExistingInactiveRegions, intelliSenseResult.isCompletePass); - this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics); + if (intelliSenseResult.clearExistingDiagnostics || intelliSenseResult.diagnostics.length > 0) { + this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics); + } } private updateSquiggles(uriString: string, diagnostics: IntelliSenseDiagnostic[], startNewSet: boolean): void { diff --git a/Extension/src/LanguageServer/lmTool.ts b/Extension/src/LanguageServer/lmTool.ts index a4461a2eed..ed5be61a00 100644 --- a/Extension/src/LanguageServer/lmTool.ts +++ b/Extension/src/LanguageServer/lmTool.ts @@ -43,13 +43,11 @@ const knownValues: { [Property in keyof ChatContextResult]?: { [id: string]: str 'macos': 'macOS' } }; -// todo revert changes before pull request export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool { public async invoke(options: vscode.LanguageModelToolInvocationOptions, token: vscode.CancellationToken): Promise { - const result: vscode.LanguageModelToolResult = { "content": [] }; - result.content.push(await this.getContext(token)); - return result; + return new vscode.LanguageModelToolResult([ + new vscode.LanguageModelTextPart(await this.getContext(token))]); } private async getContext(token: vscode.CancellationToken): Promise { diff --git a/Extension/test/scenarios/SingleRootProject/tests/copilotProviders.test.ts b/Extension/test/scenarios/SingleRootProject/tests/copilotProviders.test.ts index c06f438f8b..54052e122d 100644 --- a/Extension/test/scenarios/SingleRootProject/tests/copilotProviders.test.ts +++ b/Extension/test/scenarios/SingleRootProject/tests/copilotProviders.test.ts @@ -22,6 +22,12 @@ describe('registerRelatedFilesProvider', () => { let callbackPromise: Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }> | undefined; let vscodeExtension: vscode.Extension; + const includedFiles = process.platform === 'win32' ? + ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] : + ['/system/include/vector', '/system/include/string', '/home/src/my_project/foo.h']; + const rootUri = vscode.Uri.file(process.platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project'); + const expectedInclude = process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h'; + beforeEach(() => { proxyquire.noPreserveCache(); // Tells proxyquire to not fetch the module from cache // Ensures that each test has a freshly loaded instance of moduleUnderTest @@ -105,9 +111,9 @@ describe('registerRelatedFilesProvider', () => { it('should not add #cpp traits when ChatContext isn\'t available.', async () => { arrange({ vscodeExtension: vscodeExtension, - getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] }, + getIncludeFiles: { includedFiles }, chatContext: undefined, - rootUri: vscode.Uri.file('C:\\src\\my_project'), + rootUri, flags: { copilotcppTraits: true } }); await moduleUnderTest.registerRelatedFilesProvider(); @@ -120,14 +126,14 @@ describe('registerRelatedFilesProvider', () => { ok(callbackPromise, 'callbackPromise should be defined'); ok(result, 'result should be defined'); ok(result.entries.length === 1, 'result.entries should have 1 included file'); - ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"'); + ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`); ok(result.traits === undefined, 'result.traits should be undefined'); }); it('should not add #cpp traits when copilotcppTraits flag is false.', async () => { arrange({ vscodeExtension: vscodeExtension, - getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] }, + getIncludeFiles: { includedFiles }, chatContext: { language: 'c++', standardVersion: 'c++20', @@ -135,7 +141,7 @@ describe('registerRelatedFilesProvider', () => { targetPlatform: 'windows', targetArchitecture: 'x64' }, - rootUri: vscode.Uri.file('C:\\src\\my_project'), + rootUri, flags: { copilotcppTraits: false } }); await moduleUnderTest.registerRelatedFilesProvider(); @@ -148,14 +154,14 @@ describe('registerRelatedFilesProvider', () => { ok(callbackPromise, 'callbackPromise should be defined'); ok(result, 'result should be defined'); ok(result.entries.length === 1, 'result.entries should have 1 included file'); - ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"'); + ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`); ok(result.traits === undefined, 'result.traits should be undefined'); }); it('should add #cpp traits when copilotcppTraits flag is true.', async () => { arrange({ vscodeExtension: vscodeExtension, - getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] }, + getIncludeFiles: { includedFiles }, chatContext: { language: 'c++', standardVersion: 'c++20', @@ -163,7 +169,7 @@ describe('registerRelatedFilesProvider', () => { targetPlatform: 'windows', targetArchitecture: 'x64' }, - rootUri: vscode.Uri.file('C:\\src\\my_project'), + rootUri, flags: { copilotcppTraits: true } }); await moduleUnderTest.registerRelatedFilesProvider(); @@ -177,7 +183,7 @@ describe('registerRelatedFilesProvider', () => { ok(callbackPromise, 'callbackPromise should be defined'); ok(result, 'result should be defined'); ok(result.entries.length === 1, 'result.entries should have 1 included file'); - ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"'); + ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`); ok(result.traits, 'result.traits should be defined'); ok(result.traits.length === 5, 'result.traits should have 5 traits'); ok(result.traits[0].name === 'language', 'result.traits[0].name should be "language"'); @@ -206,7 +212,7 @@ describe('registerRelatedFilesProvider', () => { const excludeTraits = ['compiler', 'targetPlatform']; arrange({ vscodeExtension: vscodeExtension, - getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] }, + getIncludeFiles: { includedFiles }, chatContext: { language: 'c++', standardVersion: 'c++20', @@ -214,7 +220,7 @@ describe('registerRelatedFilesProvider', () => { targetPlatform: 'windows', targetArchitecture: 'x64' }, - rootUri: vscode.Uri.file('C:\\src\\my_project'), + rootUri, flags: { copilotcppTraits: true, copilotcppExcludeTraits: excludeTraits } }); await moduleUnderTest.registerRelatedFilesProvider(); @@ -228,7 +234,7 @@ describe('registerRelatedFilesProvider', () => { ok(callbackPromise, 'callbackPromise should be defined'); ok(result, 'result should be defined'); ok(result.entries.length === 1, 'result.entries should have 1 included file'); - ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"'); + ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`); ok(result.traits, 'result.traits should be defined'); ok(result.traits.length === 3, 'result.traits should have 3 traits'); ok(result.traits.filter(trait => excludeTraits.includes(trait.name)).length === 0, 'result.traits should not include excluded traits');