Skip to content

Commit a565364

Browse files
authored
Merge branch 'main' into dbaeumer/glad-guineafowl-lime
2 parents 3f48f0c + 53133e6 commit a565364

File tree

7 files changed

+64
-11
lines changed

7 files changed

+64
-11
lines changed

src/vs/editor/common/textModelEditReason.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const EditReasons = {
6464
chatApplyEdits(data: { modelId: string | undefined }) {
6565
return createEditReason({
6666
source: 'Chat.applyEdits',
67-
$modelId: data.modelId,
67+
$modelId: avoidPathRedaction(data.modelId),
6868
} as const);
6969
},
7070

@@ -90,7 +90,7 @@ export const EditReasons = {
9090
inlineChatApplyEdit(data: { modelId: string | undefined }) {
9191
return createEditReason({
9292
source: 'inlineChat.applyEdits',
93-
$modelId: avoidRedaction(data.modelId),
93+
$modelId: avoidPathRedaction(data.modelId),
9494
} as const);
9595
},
9696

@@ -116,7 +116,7 @@ export const EditReasons = {
116116
type Values<T> = T[keyof T];
117117
type ITextModelEditReasonMetadata = Values<{ [TKey in keyof typeof EditReasons]: ReturnType<typeof EditReasons[TKey]>['metadataT'] }>;
118118

119-
function avoidRedaction(str: string | undefined): string | undefined {
119+
function avoidPathRedaction(str: string | undefined): string | undefined {
120120
if (str === undefined) {
121121
return undefined;
122122
}

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,9 @@ export function registerChatActions() {
819819
registerAction2(class UpdateInstructionsAction extends Action2 {
820820
constructor() {
821821
super({
822-
id: 'workbench.action.chat.updateInstructions',
823-
title: localize2('updateInstructions', "Generate Instructions"),
824-
shortTitle: localize2('updateInstructions.short', "Generate Instructions"),
822+
id: 'workbench.action.chat.generateInstructions',
823+
title: localize2('generateInstructions', "Generate Workspace Instructions File"),
824+
shortTitle: localize2('generateInstructions.short', "Generate Instructions"),
825825
category: CHAT_CATEGORY,
826826
icon: Codicon.sparkle,
827827
f1: true,

src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class AttachFileToChatAction extends AttachResourceAction {
114114
id: AttachFileToChatAction.ID,
115115
title: localize2('workbench.action.chat.attachFile.label', "Add File to Chat"),
116116
category: CHAT_CATEGORY,
117+
precondition: ChatContextKeys.enabled,
117118
f1: true,
118119
menu: [{
119120
id: MenuId.SearchContext,
@@ -224,6 +225,7 @@ class AttachSelectionToChatAction extends Action2 {
224225
title: localize2('workbench.action.chat.attachSelection.label', "Add Selection to Chat"),
225226
category: CHAT_CATEGORY,
226227
f1: true,
228+
precondition: ChatContextKeys.enabled,
227229
menu: {
228230
id: MenuId.ChatTextEditorMenu,
229231
group: 'zContext',

src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IExtensionsWorkbenchService } from '../../../extensions/common/extensio
1717
import { IProductService } from '../../../../../platform/product/common/productService.js';
1818
import { Codicon } from '../../../../../base/common/codicons.js';
1919
import { ThemeIcon } from '../../../../../base/common/themables.js';
20+
import { ChatContextKeys } from '../../common/chatContextKeys.js';
2021

2122
class ManageLanguageModelAuthenticationAction extends Action2 {
2223
static readonly ID = 'workbench.action.chat.manageLanguageModelAuthentication';
@@ -26,6 +27,7 @@ class ManageLanguageModelAuthenticationAction extends Action2 {
2627
id: ManageLanguageModelAuthenticationAction.ID,
2728
title: localize2('manageLanguageModelAuthentication', 'Manage Language Model Access...'),
2829
category: CHAT_CATEGORY,
30+
precondition: ChatContextKeys.enabled,
2931
menu: [{
3032
id: MenuId.AccountsContext,
3133
order: 100,

src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const UPDATE_INSTRUCTIONS_OPTION: IPromptPickerQuickPickItem = Object.freeze({
130130
pickable: false,
131131
alwaysShow: true,
132132
buttons: [HELP_BUTTON],
133-
commandId: 'workbench.action.chat.updateInstructions',
133+
commandId: 'workbench.action.chat.generateInstructions',
134134
});
135135

136136
/**

src/vs/workbench/contrib/terminalContrib/zoom/browser/terminal.zoom.contribution.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
5757
return this._configurationService.getValue(TerminalSettingId.FontSize);
5858
}
5959

60+
private _clampFontSize(fontSize: number): number {
61+
return clampTerminalFontSize(fontSize);
62+
}
63+
6064
private _setupMouseWheelZoomListener(raw: RawXtermTerminal) {
6165
// This is essentially a copy of what we do in the editor, just we modify font size directly
6266
// as there is no separate zoom level concept in the terminal
@@ -72,7 +76,8 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
7276
if (classifier.isPhysicalMouseWheel()) {
7377
if (this._hasMouseWheelZoomModifiers(browserEvent)) {
7478
const delta = browserEvent.deltaY > 0 ? -1 : 1;
75-
this._configurationService.updateValue(TerminalSettingId.FontSize, this._getConfigFontSize() + delta);
79+
const newFontSize = this._clampFontSize(this._getConfigFontSize() + delta);
80+
this._configurationService.updateValue(TerminalSettingId.FontSize, newFontSize);
7681
// EditorZoom.setZoomLevel(zoomLevel + delta);
7782
browserEvent.preventDefault();
7883
browserEvent.stopPropagation();
@@ -96,7 +101,8 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
96101
const deltaAbs = Math.ceil(Math.abs(gestureAccumulatedDelta / 5));
97102
const deltaDirection = gestureAccumulatedDelta > 0 ? -1 : 1;
98103
const delta = deltaAbs * deltaDirection;
99-
this._configurationService.updateValue(TerminalSettingId.FontSize, gestureStartFontSize + delta);
104+
const newFontSize = this._clampFontSize(gestureStartFontSize + delta);
105+
this._configurationService.updateValue(TerminalSettingId.FontSize, newFontSize);
100106
gestureAccumulatedDelta += browserEvent.deltaY;
101107
browserEvent.preventDefault();
102108
browserEvent.stopPropagation();
@@ -128,7 +134,8 @@ registerTerminalAction({
128134
const configurationService = accessor.get(IConfigurationService);
129135
const value = configurationService.getValue(TerminalSettingId.FontSize);
130136
if (isNumber(value)) {
131-
await configurationService.updateValue(TerminalSettingId.FontSize, value + 1);
137+
const newFontSize = clampTerminalFontSize(value + 1);
138+
await configurationService.updateValue(TerminalSettingId.FontSize, newFontSize);
132139
}
133140
}
134141
});
@@ -140,7 +147,8 @@ registerTerminalAction({
140147
const configurationService = accessor.get(IConfigurationService);
141148
const value = configurationService.getValue(TerminalSettingId.FontSize);
142149
if (isNumber(value)) {
143-
await configurationService.updateValue(TerminalSettingId.FontSize, value - 1);
150+
const newFontSize = clampTerminalFontSize(value - 1);
151+
await configurationService.updateValue(TerminalSettingId.FontSize, newFontSize);
144152
}
145153
}
146154
});
@@ -153,3 +161,7 @@ registerTerminalAction({
153161
await configurationService.updateValue(TerminalSettingId.FontSize, defaultTerminalFontSize);
154162
}
155163
});
164+
165+
export function clampTerminalFontSize(fontSize: number): number {
166+
return Math.max(6, Math.min(100, fontSize));
167+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { strictEqual } from 'assert';
7+
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js';
8+
import { clampTerminalFontSize } from '../../browser/terminal.zoom.contribution.js';
9+
10+
suite('Terminal Mouse Wheel Zoom', () => {
11+
ensureNoDisposablesAreLeakedInTestSuite();
12+
13+
test('clamps font size to minimum value when below bounds', () => {
14+
const result = clampTerminalFontSize(3 + (-2)); // 3 - 2 = 1, clamped to 6
15+
strictEqual(result, 6, 'Font size should be clamped to minimum value of 6');
16+
});
17+
18+
test('clamps font size to maximum value when above bounds', () => {
19+
const result = clampTerminalFontSize(99 + 5); // 99 + 5 = 104, clamped to 100
20+
strictEqual(result, 100, 'Font size should be clamped to maximum value of 100');
21+
});
22+
23+
test('preserves font size when within bounds', () => {
24+
const result = clampTerminalFontSize(12 + 3); // 12 + 3 = 15, within bounds
25+
strictEqual(result, 15, 'Font size should remain unchanged when within bounds');
26+
});
27+
28+
test('clamps font size when going below minimum', () => {
29+
const result = clampTerminalFontSize(6 + (-1)); // 6 - 1 = 5, clamped to 6
30+
strictEqual(result, 6, 'Font size should be clamped when going below minimum');
31+
});
32+
33+
test('clamps font size when going above maximum', () => {
34+
const result = clampTerminalFontSize(100 + 1); // 100 + 1 = 101, clamped to 100
35+
strictEqual(result, 100, 'Font size should be clamped when going above maximum');
36+
});
37+
});

0 commit comments

Comments
 (0)