Skip to content

Commit

Permalink
Rebase against the upstream 62aabbc
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: 62aabbc
  • Loading branch information
Eclipse Che Sync committed Jan 8, 2025
2 parents dcbba85 + 62aabbc commit fec02d8
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 81 deletions.
2 changes: 1 addition & 1 deletion code/src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export class CodeApplication extends Disposable {
// Linux (stable only): custom title default style override
if (isLinux && this.productService.quality === 'stable') {
const titleBarDefaultStyleOverride = this.stateService.getItem('window.titleBarStyleOverride');
if (titleBarDefaultStyleOverride === TitlebarStyle.CUSTOM || titleBarDefaultStyleOverride === TitlebarStyle.NATIVE) {
if (titleBarDefaultStyleOverride === TitlebarStyle.CUSTOM) {
overrideDefaultTitlebarStyle(titleBarDefaultStyleOverride);
}
}
Expand Down
6 changes: 3 additions & 3 deletions code/src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4233,10 +4233,10 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
enabled: true,
useMixedLinesDiff: 'forStableInsertions',
useInterleavedLinesDiff: 'never',
useWordInsertionView: 'never',
useWordReplacementView: 'never',
useWordInsertionView: 'whenPossible',
useWordReplacementView: 'whenPossible',
onlyShowWhenCloseToCursor: true,
useGutterIndicator: false,
useGutterIndicator: true,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export class TestConfigurationService implements IConfigurationService {
}

public inspect<T>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<T> {
const config = this.getValue(undefined, overrides);
const value = this.getValue(key, overrides);

return {
value: getConfigurationValue<T>(config, key),
defaultValue: getConfigurationValue<T>(config, key),
userValue: getConfigurationValue<T>(config, key),
value,
defaultValue: undefined,
userValue: value,
overrideIdentifiers: this.overrideIdentifiers.get(key)
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export class AllowedExtensionsService extends Disposable implements IAllowedExte
}

private getAllowedExtensionsValue(): AllowedExtensionsConfigValueType | undefined {
const value = this.configurationService.getValue<AllowedExtensionsConfigValueType | undefined>(AllowedExtensionsConfigKey);
const inspectValue = this.configurationService.inspect<AllowedExtensionsConfigValueType | undefined>(AllowedExtensionsConfigKey);
const value = inspectValue.policyValue ?? inspectValue.userValue ?? inspectValue.defaultValue;
if (!isObject(value) || Array.isArray(value)) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion code/src/vs/platform/native/common/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export interface ICommonNativeHostService {
focusWindow(options?: INativeHostOptions & { force?: boolean }): Promise<void>;

// Titlebar default style override
overrideDefaultTitlebarStyle(style: 'native' | 'custom' | undefined): Promise<void>;
overrideDefaultTitlebarStyle(style: 'custom' | undefined): Promise<void>;

// Dialogs
showMessageBox(options: MessageBoxOptions & INativeHostOptions): Promise<MessageBoxReturnValue>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { IProductService } from '../../product/common/productService.js';
import { IPartsSplash } from '../../theme/common/themeService.js';
import { IThemeMainService } from '../../theme/electron-main/themeMainService.js';
import { defaultWindowState, ICodeWindow } from '../../window/electron-main/window.js';
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable, overrideDefaultTitlebarStyle } from '../../window/common/window.js';
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable } from '../../window/common/window.js';
import { defaultBrowserWindowOptions, IWindowsMainService, OpenContext } from '../../windows/electron-main/windows.js';
import { isWorkspaceIdentifier, toWorkspaceIdentifier } from '../../workspace/common/workspace.js';
import { IWorkspacesManagementMainService } from '../../workspaces/electron-main/workspacesManagementMainService.js';
Expand Down Expand Up @@ -326,13 +326,12 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
this.themeMainService.saveWindowSplash(windowId, splash);
}

async overrideDefaultTitlebarStyle(windowId: number | undefined, style: 'native' | 'custom' | undefined): Promise<void> {
if (typeof style === 'string') {
async overrideDefaultTitlebarStyle(windowId: number | undefined, style: 'custom' | undefined): Promise<void> {
if (style === 'custom') {
this.stateService.setItem('window.titleBarStyleOverride', style);
} else {
this.stateService.removeItem('window.titleBarStyleOverride');
}
overrideDefaultTitlebarStyle(style);
}

//#endregion
Expand Down
20 changes: 6 additions & 14 deletions code/src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,9 @@ export const enum CustomTitleBarVisibility {
NEVER = 'never',
}

export let titlebarStyleDefaultOverride: TitlebarStyle | undefined = undefined;
export function overrideDefaultTitlebarStyle(style: 'native' | 'custom' | undefined): void {
switch (style) {
case 'native':
titlebarStyleDefaultOverride = TitlebarStyle.NATIVE;
break;
case 'custom':
titlebarStyleDefaultOverride = TitlebarStyle.CUSTOM;
break;
default:
titlebarStyleDefaultOverride = undefined;
}
export let titlebarStyleDefaultOverride: 'custom' | undefined = undefined;
export function overrideDefaultTitlebarStyle(style: 'custom'): void {
titlebarStyleDefaultOverride = style;
}

export function hasCustomTitlebar(configurationService: IConfigurationService, titleBarStyle?: TitlebarStyle): boolean {
Expand Down Expand Up @@ -238,8 +229,8 @@ export function getTitleBarStyle(configurationService: IConfigurationService): T
}
}

if (titlebarStyleDefaultOverride) {
return titlebarStyleDefaultOverride;
if (titlebarStyleDefaultOverride === 'custom') {
return TitlebarStyle.CUSTOM;
}

return isLinux && product.quality === 'stable' ? TitlebarStyle.NATIVE : TitlebarStyle.CUSTOM; // default to custom on all OS except Linux stable (for now)
Expand Down Expand Up @@ -413,6 +404,7 @@ export interface INativeWindowConfiguration extends IWindowConfiguration, Native
autoDetectHighContrast?: boolean;
autoDetectColorScheme?: boolean;
isCustomZoomLevel?: boolean;
overrideDefaultTitlebarStyle?: 'custom';

perfMarks: PerformanceMark[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import product from '../../product/common/product.js';
import { IProtocolMainService } from '../../protocol/electron-main/protocol.js';
import { getRemoteAuthority } from '../../remote/common/remoteHosts.js';
import { IStateService } from '../../state/node/state.js';
import { IAddRemoveFoldersRequest, INativeOpenFileRequest, INativeWindowConfiguration, IOpenEmptyWindowOptions, IPath, IPathsToWaitFor, isFileToOpen, isFolderToOpen, isWorkspaceToOpen, IWindowOpenable, IWindowSettings } from '../../window/common/window.js';
import { IAddRemoveFoldersRequest, INativeOpenFileRequest, INativeWindowConfiguration, IOpenEmptyWindowOptions, IPath, IPathsToWaitFor, isFileToOpen, isFolderToOpen, isWorkspaceToOpen, IWindowOpenable, IWindowSettings, titlebarStyleDefaultOverride } from '../../window/common/window.js';
import { CodeWindow } from './windowImpl.js';
import { IOpenConfiguration, IOpenEmptyConfiguration, IWindowsCountChangedEvent, IWindowsMainService, OpenContext, getLastFocused } from './windows.js';
import { findWindowOnExtensionDevelopmentPath, findWindowOnFile, findWindowOnWorkspaceOrFolder } from './windowsFinder.js';
Expand Down Expand Up @@ -1507,6 +1507,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic

autoDetectHighContrast: windowConfig?.autoDetectHighContrast ?? true,
autoDetectColorScheme: windowConfig?.autoDetectColorScheme ?? false,
overrideDefaultTitlebarStyle: titlebarStyleDefaultOverride,
accessibilitySupport: app.accessibilitySupportEnabled,
colorScheme: this.themeMainService.getColorScheme(),
policiesData: this.policyService.serialize(),
Expand Down
40 changes: 25 additions & 15 deletions code/src/vs/workbench/contrib/chat/browser/chatEditorSaving.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IStorageService, StorageScope, StorageTarget } from '../../../../platfo
import { IWorkbenchContribution } from '../../../common/contributions.js';
import { IEditorIdentifier, SaveReason } from '../../../common/editor.js';
import { IEditorService } from '../../../services/editor/common/editorService.js';
import { IFilesConfigurationService } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
import { AutoSaveMode, IFilesConfigurationService } from '../../../services/filesConfiguration/common/filesConfigurationService.js';
import { ILifecycleService } from '../../../services/lifecycle/common/lifecycle.js';
import { ITextFileService } from '../../../services/textfile/common/textfiles.js';
import { ChatAgentLocation, IChatAgentService } from '../common/chatAgents.js';
Expand Down Expand Up @@ -116,6 +116,7 @@ export class ChatEditorSaving extends Disposable implements IWorkbenchContributi
@IConfigurationService configService: IConfigurationService,
@IChatEditingService chatEditingService: IChatEditingService,
@IChatAgentService chatAgentService: IChatAgentService,
@IFilesConfigurationService fileConfigService: IFilesConfigurationService,
@ITextFileService textFileService: ITextFileService,
@ILabelService labelService: ILabelService,
@IDialogService dialogService: IDialogService,
Expand All @@ -141,13 +142,11 @@ export class ChatEditorSaving extends Disposable implements IWorkbenchContributi
}));
}));

const store = this._store.add(new DisposableStore());

const update = () => {
const alwaysSaveConfig = observableConfigValue<boolean>(ChatEditorSaving._config, false, configService);
this._store.add(autorunWithStore((r, store) => {

store.clear();
const alwaysSave = alwaysSaveConfig.read(r);

const alwaysSave = configService.getValue<boolean>(ChatEditorSaving._config);
if (alwaysSave) {
return;
}
Expand Down Expand Up @@ -235,14 +234,27 @@ export class ChatEditorSaving extends Disposable implements IWorkbenchContributi
return saveJobs.add(entry.modifiedURI);
}
}));
};
}));

configService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(ChatEditorSaving._config)) {
update();
// autosave: OFF & alwaysSaveWithAIChanges - save files after accept
this._store.add(autorun(r => {
const saveConfig = fileConfigService.getAutoSaveMode(undefined);
if (saveConfig.mode !== AutoSaveMode.OFF) {
return;
}
});
update();
if (!alwaysSaveConfig.read(r)) {
return;
}
const session = chatEditingService.currentEditingSessionObs.read(r);
if (!session) {
return;
}
for (const entry of session.entries.read(r)) {
if (entry.state.read(r) === WorkingSetEntryState.Accepted) {
textFileService.save(entry.modifiedURI);
}
}
}));
}

private _reportSaved(entry: IModifiedFileEntry) {
Expand Down Expand Up @@ -277,13 +289,11 @@ export class ChatEditorSaving extends Disposable implements IWorkbenchContributi

export class ChatEditingSaveAllAction extends Action2 {
static readonly ID = 'chatEditing.saveAllFiles';
static readonly LABEL = localize('save.allFiles', 'Save All');

constructor() {
super({
id: ChatEditingSaveAllAction.ID,
title: ChatEditingSaveAllAction.LABEL,
tooltip: ChatEditingSaveAllAction.LABEL,
title: localize('save.allFiles', 'Save All'),
precondition: ContextKeyExpr.and(ChatContextKeys.requestInProgress.negate(), hasUndecidedChatEditingResourceContextKey),
icon: Codicon.saveAll,
menu: [
Expand Down
14 changes: 11 additions & 3 deletions code/src/vs/workbench/contrib/chat/browser/chatSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import Severity from '../../../../base/common/severity.js';
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
import { isWeb } from '../../../../base/common/platform.js';
import { ExtensionUrlHandlerOverrideRegistry } from '../../../services/extensions/browser/extensionUrlHandler.js';
import { IWorkspaceTrustRequestService } from '../../../../platform/workspace/common/workspaceTrust.js';

const defaultChat = {
extensionId: product.defaultChatAgent?.extensionId ?? '',
Expand Down Expand Up @@ -174,8 +175,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
ensureSideBarChatViewSize(400, viewDescriptorService, layoutService);

if (startSetup === true) {
const controller = that.controller.value;
controller.setup();
that.controller.value.setup();
}

configurationService.updateValue('chat.commandCenter.enabled', true);
Expand Down Expand Up @@ -728,7 +728,8 @@ class ChatSetupController extends Disposable {
@IChatAgentService private readonly chatAgentService: IChatAgentService,
@IActivityService private readonly activityService: IActivityService,
@ICommandService private readonly commandService: ICommandService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService
) {
super();

Expand Down Expand Up @@ -792,6 +793,13 @@ class ChatSetupController extends Disposable {
}
}

const trusted = await this.workspaceTrustRequestService.requestWorkspaceTrust({
message: localize('copilotWorkspaceTrust', "Copilot is currently only supported in trusted workspaces.")
});
if (!trusted) {
return;
}

const activeElement = getActiveElement();

// Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,9 @@ suite('ExtensionsWorkbenchServiceTest', () => {
return true;
},
});
},
inspect: (key: string) => {
return {};
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { ModifierKeyEmitter } from '../../base/browser/dom.js';
import { applicationConfigurationNodeBase, securityConfigurationNodeBase } from '../common/configuration.js';
import { MAX_ZOOM_LEVEL, MIN_ZOOM_LEVEL } from '../../platform/window/electron-sandbox/window.js';
import product from '../../platform/product/common/product.js';
import { registerWorkbenchContribution2, WorkbenchPhase } from '../common/contributions.js';
import { LinuxCustomTitlebarExperiment } from './parts/titlebar/titlebarPart.js';

// Actions
(function registerActions(): void {
Expand Down Expand Up @@ -234,7 +236,6 @@ import product from '../../platform/product/common/product.js';
'type': 'string',
'enum': ['native', 'custom'],
'default': isLinux && product.quality === 'stable' ? 'native' : 'custom',
'tags': isLinux && product.quality === 'stable' ? ['onExP'] : undefined,
'scope': ConfigurationScope.APPLICATION,
'description': localize('titleBarStyle', "Adjust the appearance of the window title bar to be native by the OS or custom. On Linux and Windows, this setting also affects the application and context menu appearances. Changes require a full restart to apply."),
},
Expand Down Expand Up @@ -424,3 +425,6 @@ import product from '../../platform/product/common/product.js';

jsonRegistry.registerSchema(argvDefinitionFileSchemaId, schema);
})();

// Workbench Contributions
registerWorkbenchContribution2(LinuxCustomTitlebarExperiment.ID, LinuxCustomTitlebarExperiment, WorkbenchPhase.Eventually);
10 changes: 9 additions & 1 deletion code/src/vs/workbench/electron-sandbox/desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { WorkspaceTrustEnablementService, WorkspaceTrustManagementService } from
import { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService } from '../../platform/workspace/common/workspaceTrust.js';
import { safeStringify } from '../../base/common/objects.js';
import { IUtilityProcessWorkerWorkbenchService, UtilityProcessWorkerWorkbenchService } from '../services/utilityProcess/electron-sandbox/utilityProcessWorkerWorkbenchService.js';
import { isBigSurOrNewer, isCI, isMacintosh } from '../../base/common/platform.js';
import { isBigSurOrNewer, isCI, isLinux, isMacintosh } from '../../base/common/platform.js';
import { Schemas } from '../../base/common/network.js';
import { DiskFileSystemProvider } from '../services/files/electron-sandbox/diskFileSystemProvider.js';
import { FileUserDataProvider } from '../../platform/userData/common/fileUserDataProvider.js';
Expand All @@ -61,6 +61,8 @@ import { ElectronRemoteResourceLoader } from '../../platform/remote/electron-san
import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
import { applyZoom } from '../../platform/window/electron-sandbox/window.js';
import { mainWindow } from '../../base/browser/window.js';
import { Registry } from '../../platform/registry/common/platform.js';
import { IConfigurationRegistry, Extensions } from '../../platform/configuration/common/configurationRegistry.js';

export class DesktopMain extends Disposable {

Expand All @@ -79,6 +81,12 @@ export class DesktopMain extends Disposable {

// Apply fullscreen early if configured
setFullscreen(!!this.configuration.fullscreen, mainWindow);

// Apply custom title override to defaults if any
if (isLinux && product.quality === 'stable' && this.configuration.overrideDefaultTitlebarStyle === 'custom') {
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
configurationRegistry.registerDefaultConfigurations([{ overrides: { 'window.titleBarStyle': 'custom' } }]);
}
}

private reviveUris() {
Expand Down
Loading

0 comments on commit fec02d8

Please sign in to comment.