Skip to content

Commit

Permalink
Rebase against the upstream dfb96d1
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: dfb96d1
  • Loading branch information
Eclipse Che Sync committed Aug 29, 2024
2 parents 206357e + dfb96d1 commit e605e8b
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 50 deletions.
3 changes: 2 additions & 1 deletion code/build/lib/stylelint/vscode-known-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@
"--testMessageDecorationFontFamily",
"--testMessageDecorationFontSize",
"--title-border-bottom-color",
"--title-wco-width",
"--vscode-chat-list-background",
"--vscode-editorCodeLens-fontFamily",
"--vscode-editorCodeLens-fontFamilyDefault",
Expand Down Expand Up @@ -880,4 +881,4 @@
"--widget-color",
"--text-link-decoration"
]
}
}
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "che-code",
"version": "1.93.0",
"distro": "a2c246f88376de52724ad8d87645866893d1aa49",
"distro": "2560b0e8d341a0b6734d28ef71b08e1920ff2501",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
4 changes: 2 additions & 2 deletions code/src/vs/base/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ export function isWCOEnabled(): boolean {

// Returns the bounding rect of the titlebar area if it is supported and defined
// See docs at https://developer.mozilla.org/en-US/docs/Web/API/WindowControlsOverlay/getTitlebarAreaRect
export function getWCOBoundingRect(): DOMRect | undefined {
return (navigator as any)?.windowControlsOverlay?.getTitlebarAreaRect();
export function getWCOTitlebarAreaRect(targetWindow: Window): DOMRect | undefined {
return (targetWindow.navigator as any)?.windowControlsOverlay?.getTitlebarAreaRect();
}
18 changes: 0 additions & 18 deletions code/src/vs/base/parts/sandbox/common/electronTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,6 @@ export interface FileFilter {
name: string;
}

export interface OpenDevToolsOptions {
/**
* Opens the devtools with specified dock state, can be `left`, `right`, `bottom`,
* `undocked`, `detach`. Defaults to last used dock state. In `undocked` mode it's
* possible to dock back. In `detach` mode it's not.
*/
mode: ('left' | 'right' | 'bottom' | 'undocked' | 'detach');
/**
* Whether to bring the opened devtools window to the foreground. The default is
* `true`.
*/
activate?: boolean;
/**
* A title for the DevTools window (only in `undocked` or `detach` mode).
*/
title?: string;
}

interface InputEvent {

// Docs: https://electronjs.org/docs/api/structures/input-event
Expand Down
4 changes: 2 additions & 2 deletions code/src/vs/platform/native/common/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { VSBuffer } from 'vs/base/common/buffer';
import { Event } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'vs/base/parts/sandbox/common/electronTypes';
import { MessageBoxOptions, MessageBoxReturnValue, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'vs/base/parts/sandbox/common/electronTypes';
import { ISerializableCommandAction } from 'vs/platform/action/common/action';
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -178,7 +178,7 @@ export interface ICommonNativeHostService {
exit(code: number): Promise<void>;

// Development
openDevTools(options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void>;
openDevTools(options?: INativeHostOptions): Promise<void>;
toggleDevTools(options?: INativeHostOptions): Promise<void>;

// Perf Introspection
Expand Down
24 changes: 19 additions & 5 deletions code/src/vs/platform/native/electron-main/nativeHostMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as fs from 'fs';
import { exec } from 'child_process';
import { app, BrowserWindow, clipboard, Display, Menu, MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, powerMonitor, SaveDialogOptions, SaveDialogReturnValue, screen, shell, webContents } from 'electron';
import { app, BrowserWindow, clipboard, Display, Menu, MessageBoxOptions, MessageBoxReturnValue, OpenDialogOptions, OpenDialogReturnValue, powerMonitor, SaveDialogOptions, SaveDialogReturnValue, screen, shell, webContents } from 'electron';
import { arch, cpus, freemem, loadavg, platform, release, totalmem, type } from 'os';
import { promisify } from 'util';
import { memoize } from 'vs/base/common/decorators';
Expand Down Expand Up @@ -33,7 +33,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { IPartsSplash } from 'vs/platform/theme/common/themeService';
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
import { ICodeWindow } from 'vs/platform/window/electron-main/window';
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable } from 'vs/platform/window/common/window';
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable, useWindowControlsOverlay } from 'vs/platform/window/common/window';
import { IWindowsMainService, OpenContext } from 'vs/platform/windows/electron-main/windows';
import { isWorkspaceIdentifier, toWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
Expand Down Expand Up @@ -855,14 +855,28 @@ export class NativeHostMainService extends Disposable implements INativeHostMain

//#region Development

async openDevTools(windowId: number | undefined, options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void> {
async openDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
const window = this.windowById(options?.targetWindowId, windowId);
window?.win?.webContents.openDevTools(options?.mode ? { mode: options.mode, activate: options.activate } : undefined);

let mode: 'bottom' | undefined = undefined;
if (isLinux && useWindowControlsOverlay(this.configurationService)) {
mode = 'bottom'; // TODO@bpasero WCO and devtools collide with default option 'right'
}
window?.win?.webContents.openDevTools(mode ? { mode } : undefined);
}

async toggleDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
const window = this.windowById(options?.targetWindowId, windowId);
window?.win?.webContents.toggleDevTools();
const webContents = window?.win?.webContents;
if (!webContents) {
return;
}

if (isLinux && useWindowControlsOverlay(this.configurationService) && !webContents.isDevToolsOpened()) {
webContents.openDevTools({ mode: 'bottom' }); // TODO@bpasero WCO and devtools collide with default option 'right'
} else {
webContents.toggleDevTools();
}
}

//#endregion
Expand Down
3 changes: 0 additions & 3 deletions code/src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { FileType } from 'vs/platform/files/common/files';
import { ILoggerResource, LogLevel } from 'vs/platform/log/common/log';
import { PolicyDefinition, PolicyValue } from 'vs/platform/policy/common/policy';
import product from 'vs/platform/product/common/product';
import { IPartsSplash } from 'vs/platform/theme/common/themeService';
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IAnyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
Expand Down Expand Up @@ -240,8 +239,6 @@ export function useWindowControlsOverlay(configurationService: IConfigurationSer
if (typeof setting === 'boolean') {
return setting;
}

return product.quality !== 'stable'; // disable by default in stable for now (TODO@bpasero TODO@benibenj flip when custom title is default)
}

// Default to true.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@
}

.monaco-workbench.linux:not(.web) .part.titlebar .window-controls-container.wco-enabled {
width: calc(100px / var(--zoom-factor, 1)); /* TODO@bpasero TODO@benibenj this should not be hardcoded (https://github.com/microsoft/vscode/issues/226804) */
width: calc(var(--title-wco-width, 138px) / var(--zoom-factor, 1));
}

.monaco-workbench.linux:not(.web) .part.titlebar .titlebar-container.counter-zoom .window-controls-container.wco-enabled {
width: 100px; /* TODO@bpasero TODO@benibenj this should not be hardcoded (https://github.com/microsoft/vscode/issues/226804) */
width: var(--title-wco-width, 138px);
}

.monaco-workbench:not(.web):not(.mac) .part.titlebar .titlebar-container:not(.counter-zoom) .window-controls-container * {
Expand Down Expand Up @@ -388,7 +388,6 @@
z-index: 2500;
-webkit-app-region: no-drag;
height: 100%;
min-width: 28px;
}

.monaco-workbench .part.titlebar > .titlebar-container > .titlebar-right > .action-toolbar-container {
Expand Down
11 changes: 9 additions & 2 deletions code/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'vs/css!./media/titlebarpart';
import { localize, localize2 } from 'vs/nls';
import { MultiWindowParts, Part } from 'vs/workbench/browser/part';
import { ITitleService } from 'vs/workbench/services/title/browser/titleService';
import { getWCOBoundingRect, getZoomFactor, isWCOEnabled } from 'vs/base/browser/browser';
import { getWCOTitlebarAreaRect, getZoomFactor, isWCOEnabled } from 'vs/base/browser/browser';
import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, TitlebarStyle, hasCustomTitlebar, hasNativeTitlebar, DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
Expand Down Expand Up @@ -228,7 +228,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
const wcoEnabled = isWeb && isWCOEnabled();
let value = this.isCommandCenterVisible || wcoEnabled ? DEFAULT_CUSTOM_TITLEBAR_HEIGHT : 30;
if (wcoEnabled) {
value = Math.max(value, getWCOBoundingRect()?.height ?? 0);
value = Math.max(value, getWCOTitlebarAreaRect(getWindow(this.element))?.height ?? 0);
}

return value / (this.preventZoom ? getZoomFactor(getWindow(this.element)) : 1);
Expand Down Expand Up @@ -499,6 +499,13 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
this.windowControlsContainer = append(windowControlsLocation === 'left' ? this.leftContent : this.rightContent, $('div.window-controls-container'));
if (isWCOEnabled()) {
this.windowControlsContainer.classList.add('wco-enabled');

const targetWindow = getWindow(this.element);
const wcoTitlebarAreaRect = getWCOTitlebarAreaRect(targetWindow);
if (wcoTitlebarAreaRect) {
const wcoWidth = targetWindow.innerWidth - wcoTitlebarAreaRect.width - wcoTitlebarAreaRect.x;
this.windowControlsContainer.style.setProperty('--title-wco-width', `${wcoWidth}px`);
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions code/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,11 @@ export class CodeCompareBlockPart extends Disposable {
});

dom.reset(this.messageElement, message);

}

const diffData = await data.diffData;
if (!diffData) {
return;
}

if (!isEditApplied) {
if (!isEditApplied && diffData) {
const viewModel = this.diffEditor.createViewModel({
original: diffData.original,
modified: diffData.modified
Expand All @@ -801,6 +797,7 @@ export class CodeCompareBlockPart extends Disposable {
} else {
this.diffEditor.setModel(null);
this._lastDiffEditorViewModel.value = undefined;
this._onDidChangeContentHeight.fire();
}

this.toolbar.context = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class StashedSession {
// keep session for a little bit, only release when user continues to work (type, move cursor, etc.)
this._session = session;
this._ctxHasStashedSession.set(true);
this._listener = Event.once(Event.any(editor.onDidChangeCursorSelection, editor.onDidChangeModelContent, editor.onDidChangeModel))(() => {
this._listener = Event.once(Event.any(editor.onDidChangeCursorSelection, editor.onDidChangeModelContent, editor.onDidChangeModel, editor.onDidBlurEditorWidget))(() => {
this._session = undefined;
this._sessionService.releaseSession(session);
this._ctxHasStashedSession.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class InlineChatWidget {
h('div.accessibleViewer@accessibleViewer'),
h('div.status@status', [
h('div.label.info.hidden@infoLabel'),
h('div.actions.button-style.hidden@toolbar1'),
h('div.actions.hidden@toolbar1'),
h('div.label.status.hidden@statusLabel'),
h('div.actions.button-style.hidden@toolbar2'),
h('div.actions.secondary.hidden@toolbar2'),
]),
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@
gap: 4px;
}

.monaco-workbench .inline-chat .status .actions.secondary {
display: none;
}

.monaco-workbench .inline-chat .status:hover .actions.secondary,
.monaco-workbench .inline-chat:focus .status .actions.secondary,
.monaco-workbench .inline-chat .status:focus-within .actions.secondary {
display: inherit;
}

.monaco-workbench .inline-chat-diff-overlay {

.monaco-button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ __vsc_restore_exit_code() {

__vsc_prompt_cmd_original() {
__vsc_status="$?"
builtin local cmd
__vsc_restore_exit_code "${__vsc_status}"
# Evaluate the original PROMPT_COMMAND similarly to how bash would normally
# See https://unix.stackexchange.com/a/672843 for technique
builtin local cmd
for cmd in "${__vsc_original_prompt_command[@]}"; do
eval "${cmd:-}"
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function Send-Completions {
# Add `../ relative to the top completion
$firstCompletion = $completions.CompletionMatches[0]
if ($firstCompletion.CompletionText.StartsWith("..$([System.IO.Path]::DirectorySeparatorChar)")) {
if ($completionPrefix -match "(\.\.$([System.IO.Path]::DirectorySeparatorChar))+") {
if ($completionPrefix -match "(\.\.\$([System.IO.Path]::DirectorySeparatorChar))+") {
$parentDir = "$($matches[0])..$([System.IO.Path]::DirectorySeparatorChar)"
$currentPath = Split-Path -Parent $firstCompletion.ToolTip
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { NativeWindow } from 'vs/workbench/electron-sandbox/window';
import { ModifierKeyEmitter } from 'vs/base/browser/dom';
import { applicationConfigurationNodeBase, securityConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { MAX_ZOOM_LEVEL, MIN_ZOOM_LEVEL } from 'vs/platform/window/electron-sandbox/window';
import product from 'vs/platform/product/common/product';

// Actions
(function registerActions(): void {
Expand Down Expand Up @@ -240,7 +239,7 @@ import product from 'vs/platform/product/common/product';
'type': 'boolean',
'included': isLinux,
'markdownDescription': localize('window.experimentalControlOverlay', "Show the native window controls when {0} is set to `custom` (Linux only).", '`#window.titleBarStyle#`'),
'default': product.quality !== 'stable', // TODO@bpasero disable by default in stable for now (TODO@bpasero TODO@benibenj flip when custom title is default)
'default': true
},
'window.customTitleBarVisibility': {
'type': 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class TestNativeHostService implements INativeHostService {
async closeWindow(): Promise<void> { }
async quit(): Promise<void> { }
async exit(code: number): Promise<void> { }
async openDevTools(options?: Partial<Electron.OpenDevToolsOptions> & INativeHostOptions | undefined): Promise<void> { }
async openDevTools(): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
async lookupAuthorization(authInfo: AuthInfo): Promise<Credentials | undefined> { return undefined; }
Expand Down

0 comments on commit e605e8b

Please sign in to comment.