mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 08:15:56 +01:00
aiCustomization: make plugin/extension/builtin files read-only (#302592)
* aiCustomization: make plugin/extension/builtin files read-only - Open plugin, extension, and built-in customization files as read-only in the editor, with a message explaining they cannot be edited. - Extract isReadonlyStorage() helper to DRY the repeated storage type check used in both the open and delete actions. Fixes https://github.com/microsoft/vscode/issues/301292 (Commit message generated by Copilot) * pr comments
This commit is contained in:
@@ -44,6 +44,8 @@ import { Schemas } from '../../../../../base/common/network.js';
|
||||
import { isWindows, isMacintosh } from '../../../../../base/common/platform.js';
|
||||
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js';
|
||||
import { IClipboardService } from '../../../../../platform/clipboard/common/clipboardService.js';
|
||||
import { getCodeEditor } from '../../../../../editor/browser/editorBrowser.js';
|
||||
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
|
||||
import { IAgentPluginService } from '../../common/plugins/agentPluginService.js';
|
||||
|
||||
//#region Telemetry
|
||||
@@ -164,9 +166,19 @@ registerAction2(class extends Action2 {
|
||||
}
|
||||
async run(accessor: ServicesAccessor, context: AICustomizationContext): Promise<void> {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
await editorService.openEditor({
|
||||
const storage = extractStorage(context);
|
||||
|
||||
const editorPane = await editorService.openEditor({
|
||||
resource: extractURI(context)
|
||||
});
|
||||
|
||||
const codeEditor = getCodeEditor(editorPane?.getControl());
|
||||
if (codeEditor && (storage === PromptsStorage.extension || storage === PromptsStorage.plugin)) {
|
||||
codeEditor.updateOptions({
|
||||
readOnly: true,
|
||||
readOnlyMessage: new MarkdownString(localize('readonlyPluginFile', "This file is provided by a plugin or extension and cannot be edited.")),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user