Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Improvements:
- Display info tooltip when hovering over CMake policy identifiers (e.g., `CMP0177`), showing the CMake version that introduced the policy, a short description, and a link to the official documentation. [#4544](https://github.com/microsoft/vscode-cmake-tools/issues/4544)

Bug Fixes:
- Enable Ctrl+S (and File > Save) keyboard shortcut to work in the CMake Cache Editor UI. [#4000](https://github.com/microsoft/vscode-cmake-tools/issues/4000)
- Fix configure/build sometimes using stale preset values when unsaved changes to included preset files are auto-saved before configure. The extension now explicitly refreshes presets from disk after saving, instead of relying solely on the asynchronous file watcher. [#4502](https://github.com/microsoft/vscode-cmake-tools/issues/4502)
- Reduce overly verbose logging when CMake configure or build fails. The Output panel no longer floods with duplicated output, and the channel is only revealed on error rather than unconditionally. [#4749](https://github.com/microsoft/vscode-cmake-tools/issues/4749)
- Fix Test Results panel not hyperlinking file paths for GoogleTest failures. The default `cmake.ctest.failurePatterns` now includes a pattern matching GoogleTest's `file:line: Failure` output format. [#4589](https://github.com/microsoft/vscode-cmake-tools/issues/4589)
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"workspaceContains:.vscode/cmake-kits.json",
"onFileSystem:cmake-tools-schema",
"onLanguage:cmake",
"onLanguage:cmake-cache"
"onLanguage:cmake-cache",
"onCustomEditor:cmake.cmakeCacheEditor"
],
"extensionPack": [
"ms-vscode.cpp-devtools"
Expand Down Expand Up @@ -143,6 +144,18 @@
"path": "./syntaxes/CMakeCache.tmLanguage.json"
}
],
"customEditors": [
{
"viewType": "cmake.cmakeCacheEditor",
"displayName": "%cmake-tools.customEditors.cmakeCacheEditor.displayName%",
"selector": [
{
"filenamePattern": "CMakeCache.txt"
}
],
"priority": "option"
}
],
"commands": [
{
"command": "cmake.openCMakePresets",
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,5 +426,6 @@
"cmake-tools.debugger.label": "CMake Debugger",
"cmake-tools.command.cmake.appendBuildDirectoryToWorkspace.title": "Append Build Directory to Current Workspace",
"cmake-tools.command.workbench.action.tasks.configureTaskRunner.title":"Configure Task",
"cmake-tools.command.workbench.action.tasks.runTask.title":"Run Task"
"cmake-tools.command.workbench.action.tasks.runTask.title":"Run Task",
"cmake-tools.customEditors.cmakeCacheEditor.displayName": "CMake Cache Editor"
}
37 changes: 9 additions & 28 deletions src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import rollbar from '@cmt/rollbar';
import * as telemetry from '@cmt/telemetry';
import { VariantManager } from '@cmt/kits/variant';
import * as nls from 'vscode-nls';
import { ConfigurationWebview } from '@cmt/ui/cacheView';
import { enableFullFeatureSet, extensionManager, updateFullFeatureSet, setContextAndStore } from '@cmt/extension';
import { CMakeCommunicationMode, ConfigurationReader, OptionConfig, UseCMakePresets, checkConfigureOverridesPresent } from '@cmt/config';
import * as preset from '@cmt/presets/preset';
Expand Down Expand Up @@ -865,11 +864,6 @@ export class CMakeProject {
*/
private cmakeDriver: Promise<CMakeDriver | null> = Promise.resolve(null);

/**
* This object manages the CMake Cache Editor GUI
*/
private cacheEditorWebview: ConfigurationWebview | undefined;

/**
* Event fired just as CMakeProject is about to be disposed
*/
Expand Down Expand Up @@ -2007,11 +2001,6 @@ export class CMakeProject {
const filePath = util.platformNormalizePath(uri.fsPath);
const driver: CMakeDriver | null = await this.getCMakeDriverInstance();

// If we detect a change in the CMake cache file, refresh the webview
if (this.cacheEditorWebview && driver && filePath === util.platformNormalizePath(driver.cachePath)) {
await this.cacheEditorWebview.refreshPanel();
}

const sourceDirectory = util.platformNormalizePath(this.sourceDir);

let isCmakeFile: boolean;
Expand Down Expand Up @@ -2275,25 +2264,17 @@ export class CMakeProject {
* Implementation of `cmake.EditCacheUI`
*/
async editCacheUI(): Promise<number> {
if (!this.cacheEditorWebview) {
const drv = await this.getCMakeDriverInstance();
if (!drv) {
void vscode.window.showErrorMessage(localize('cache.load.failed', 'No CMakeCache.txt file has been found. Please configure project first!'));
return 1;
}

this.cacheEditorWebview = new ConfigurationWebview(drv.cachePath, () => {
void this.configureInternal(ConfigureTrigger.commandEditCacheUI, [], ConfigureType.Cache);
});
await this.cacheEditorWebview.initPanel();

this.cacheEditorWebview.panel.onDidDispose(() => {
this.cacheEditorWebview = undefined;
});
} else {
this.cacheEditorWebview.panel.reveal();
const drv = await this.getCMakeDriverInstance();
if (!drv) {
void vscode.window.showErrorMessage(localize('cache.load.failed', 'No CMakeCache.txt file has been found. Please configure project first!'));
return 1;
}

// Open the CMakeCache.txt file with our custom editor
// This uses the CustomTextEditorProvider which supports Ctrl+S save functionality
const cacheUri = vscode.Uri.file(drv.cachePath);
await vscode.commands.executeCommand('vscode.openWith', cacheUri, 'cmake.cmakeCacheEditor');

return 0;
}

Expand Down
15 changes: 15 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { DebugConfigurationProvider, DynamicDebugConfigurationProvider } from '@
import { deIntegrateTestExplorer } from "@cmt/ctest";
import collections from '@cmt/diagnostics/collections';
import { LanguageServiceData } from './languageServices/languageServiceData';
import { CMakeCacheEditorProvider } from '@cmt/ui/cmakeCacheEditorProvider';

nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
Expand Down Expand Up @@ -2707,13 +2708,27 @@ export async function activate(context: vscode.ExtensionContext): Promise<api.CM

// Register a protocol handler to serve localized schemas
vscode.workspace.registerTextDocumentContentProvider('cmake-tools-schema', new SchemaProvider());

await setContextAndStore("inCMakeProject", true);

taskProvider = vscode.tasks.registerTaskProvider(CMakeTaskProvider.CMakeScriptType, cmakeTaskProvider);
// Load a new extension manager
extensionManager = await ExtensionManager.create(context);
await extensionManager.init();

// Register the CMake Cache Editor custom text editor provider
// This enables Ctrl+S to save in the CMake Cache Editor UI
// Registered after extensionManager is initialized to ensure it's available in the callback
context.subscriptions.push(CMakeCacheEditorProvider.register(context, () => {
// Trigger reconfigure after saving the cache
if (extensionManager) {
const project = extensionManager.getActiveProject();
if (project) {
void project.configureInternal(ConfigureTrigger.commandEditCacheUI, [], ConfigureType.Cache);
}
}
}));

// need the extensionManager to be initialized for this.
pinnedCommands = new PinnedCommands(extensionManager.getWorkspaceConfig(), extensionManager.extensionContext);

Expand Down
Loading
Loading