Skip to content

Commit

Permalink
Rebase against the upstream 047cf79
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: 047cf79
  • Loading branch information
Eclipse Che Sync committed Nov 20, 2023
2 parents 3d97567 + 047cf79 commit 61ab6ee
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 83 deletions.
5 changes: 1 addition & 4 deletions code/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,5 @@
"src/vs/workbench/api/common/extHostTypes.ts"
],
// Temporarily enabled for self-hosting
"terminal.integrated.stickyScroll.enabled": true,
// Temporarily enabled for self-hosting
"scm.showIncomingChanges": "always",
"scm.showOutgoingChanges": "always",
"terminal.integrated.stickyScroll.enabled": true
}
28 changes: 13 additions & 15 deletions code/extensions/ipynb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"publisher": "vscode",
"version": "1.0.0",
"license": "MIT",
"icon": "media/icon.png",
"icon": "media/icon.png",
"engines": {
"vscode": "^1.57.0"
},
Expand Down Expand Up @@ -58,10 +58,10 @@
"command": "ipynb.cleanInvalidImageAttachment",
"title": "%cleanInvalidImageAttachment.title%"
},
{
"command": "notebook.cellOutput.copy",
"title": "%copyCellOutput.title%"
}
{
"command": "notebook.cellOutput.copy",
"title": "%copyCellOutput.title%"
}
],
"notebooks": [
{
Expand Down Expand Up @@ -105,12 +105,12 @@
"when": "false"
}
],
"webview/context": [
{
"command": "notebook.cellOutput.copy",
"when": "webviewId == 'notebook.output' && webviewSection == 'image'"
}
]
"webview/context": [
{
"command": "notebook.cellOutput.copy",
"when": "webviewId == 'notebook.output' && webviewSection == 'image'"
}
]
}
},
"scripts": {
Expand All @@ -120,13 +120,11 @@
},
"dependencies": {
"@enonic/fnv-plus": "^1.3.0",
"detect-indent": "^6.0.0",
"uuid": "^8.3.2"
"detect-indent": "^6.0.0"
},
"devDependencies": {
"@jupyterlab/nbformat": "^3.2.9",
"@types/markdown-it": "12.2.3",
"@types/uuid": "^8.3.1"
"@types/markdown-it": "12.2.3"
},
"repository": {
"type": "git",
Expand Down
56 changes: 54 additions & 2 deletions code/extensions/ipynb/src/cellIdService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/

import { ExtensionContext, NotebookDocument, NotebookDocumentChangeEvent, NotebookEdit, workspace, WorkspaceEdit } from 'vscode';
import { v4 as uuid } from 'uuid';
import { getCellMetadata } from './serializers';
import { CellMetadata } from './common';
import { getNotebookMetadata } from './notebookSerializer';
Expand Down Expand Up @@ -57,7 +56,7 @@ function generateCellId(notebook: NotebookDocument) {
while (true) {
// Details of the id can be found here https://jupyter.org/enhancement-proposals/62-cell-id/cell-id.html#adding-an-id-field,
// & here https://jupyter.org/enhancement-proposals/62-cell-id/cell-id.html#updating-older-formats
const id = uuid().replace(/-/g, '').substring(0, 8);
const id = generateUuid().replace(/-/g, '').substring(0, 8);
let duplicate = false;
for (let index = 0; index < notebook.cellCount; index++) {
const cell = notebook.cellAt(index);
Expand All @@ -75,3 +74,56 @@ function generateCellId(notebook: NotebookDocument) {
}
}
}


/**
* Copied from src/vs/base/common/uuid.ts
*/
function generateUuid() {
// use `randomValues` if possible
function getRandomValues(bucket: Uint8Array): Uint8Array {
for (let i = 0; i < bucket.length; i++) {
bucket[i] = Math.floor(Math.random() * 256);
}
return bucket;
}

// prep-work
const _data = new Uint8Array(16);
const _hex: string[] = [];
for (let i = 0; i < 256; i++) {
_hex.push(i.toString(16).padStart(2, '0'));
}

// get data
getRandomValues(_data);

// set version bits
_data[6] = (_data[6] & 0x0f) | 0x40;
_data[8] = (_data[8] & 0x3f) | 0x80;

// print as string
let i = 0;
let result = '';
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += '-';
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += '-';
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += '-';
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += '-';
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
result += _hex[_data[i++]];
return result;
}
10 changes: 0 additions & 10 deletions code/extensions/ipynb/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@
resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9"
integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==

"@types/uuid@^8.3.1":
version "8.3.4"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==

detect-indent@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6"
integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"native-watchdog": "^1.4.1",
"node-pty": "1.1.0-beta5",
"tas-client-umd": "0.1.8",
"util": "^0.12.4",
"v8-inspect-profiler": "^0.1.0",
"vscode-oniguruma": "1.7.0",
"vscode-regexpp": "^3.1.0",
Expand Down Expand Up @@ -213,6 +212,7 @@
"tsec": "0.2.7",
"typescript": "^5.4.0-dev.20231116",
"typescript-formatter": "7.1.0",
"util": "^0.12.4",
"vscode-nls-dev": "^3.3.1",
"webpack": "^5.77.0",
"webpack-cli": "^5.0.1",
Expand Down
15 changes: 9 additions & 6 deletions code/src/vs/base/node/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import * as path from 'vs/base/common/path';
import { assertIsDefined } from 'vs/base/common/types';
import { Promises } from 'vs/base/node/pfs';
import * as nls from 'vs/nls';
import { Entry, open as _openZip, ZipFile } from 'yauzl';
import * as yazl from 'yazl';
import type { Entry, ZipFile } from 'yauzl';

export const CorruptZipMessage: string = 'end of central directory record signature not found';
const CORRUPT_ZIP_PATTERN = new RegExp(CorruptZipMessage);
Expand Down Expand Up @@ -161,9 +160,11 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, tok
}).finally(() => listener.dispose());
}

function openZip(zipFile: string, lazy: boolean = false): Promise<ZipFile> {
async function openZip(zipFile: string, lazy: boolean = false): Promise<ZipFile> {
const { open } = await import('yauzl');

return new Promise<ZipFile>((resolve, reject) => {
_openZip(zipFile, lazy ? { lazyEntries: true } : undefined!, (error?: Error, zipfile?: ZipFile) => {
open(zipFile, lazy ? { lazyEntries: true } : undefined!, (error?: Error, zipfile?: ZipFile) => {
if (error) {
reject(toExtractError(error));
} else {
Expand Down Expand Up @@ -191,9 +192,11 @@ export interface IFile {
localPath?: string;
}

export function zip(zipPath: string, files: IFile[]): Promise<string> {
export async function zip(zipPath: string, files: IFile[]): Promise<string> {
const { ZipFile } = await import('yazl');

return new Promise<string>((c, e) => {
const zip = new yazl.ZipFile();
const zip = new ZipFile();
files.forEach(f => {
if (f.contents) {
zip.addBuffer(typeof f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nativeKeymap from 'native-keymap';
import type * as nativeKeymap from 'native-keymap';
import * as platform from 'vs/base/common/platform';
import { Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
Expand Down
2 changes: 1 addition & 1 deletion code/src/vs/platform/log/node/spdlogLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as spdlog from '@vscode/spdlog';
import type * as spdlog from '@vscode/spdlog';
import { ByteSize } from 'vs/platform/files/common/files';
import { AbstractMessageLogger, ILogger, LogLevel } from 'vs/platform/log/common/log';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { WindowProfiler } from 'vs/platform/profiling/electron-main/windowProfil
import { IV8Profile } from 'vs/platform/profiling/common/profiling';
import { IAuxiliaryWindowsMainService, isAuxiliaryWindow } from 'vs/platform/auxiliaryWindow/electron-main/auxiliaryWindows';
import { IAuxiliaryWindow } from 'vs/platform/auxiliaryWindow/electron-main/auxiliaryWindow';
import { loadSystemCertificates } from '@vscode/proxy-agent';

export interface INativeHostMainService extends AddFirstParameterToFunctions<ICommonNativeHostService, Promise<unknown> /* only methods, not events */, number | undefined /* window ID */> { }

Expand Down Expand Up @@ -766,7 +765,8 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
}

async loadCertificates(_windowId: number | undefined): Promise<string[]> {
return loadSystemCertificates({ log: this.logService });
const proxyAgent = await import('@vscode/proxy-agent');
return proxyAgent.loadSystemCertificates({ log: this.logService });
}

findFreePort(windowId: number | undefined, startPort: number, giveUpAfter: number, timeout: number, stride = 1): Promise<number> {
Expand Down
4 changes: 3 additions & 1 deletion code/src/vs/platform/policy/node/nativePolicyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AbstractPolicyService, IPolicyService, PolicyDefinition } from 'vs/platform/policy/common/policy';
import { IStringDictionary } from 'vs/base/common/collections';
import { Throttler } from 'vs/base/common/async';
import { createWatcher, PolicyUpdate, Watcher } from '@vscode/policy-watcher';
import type { PolicyUpdate, Watcher } from '@vscode/policy-watcher';
import { MutableDisposable } from 'vs/base/common/lifecycle';
import { ILogService } from 'vs/platform/log/common/log';

Expand All @@ -25,6 +25,8 @@ export class NativePolicyService extends AbstractPolicyService implements IPolic
protected async _updatePolicyDefinitions(policyDefinitions: IStringDictionary<PolicyDefinition>): Promise<void> {
this.logService.trace(`NativePolicyService#_updatePolicyDefinitions - Found ${Object.keys(policyDefinitions).length} policy definitions`);

const { createWatcher } = await import('@vscode/policy-watcher');

await this.throttler.queue(() => new Promise<void>((c, e) => {
try {
this.watcher.value = createWatcher(this.productName, policyDefinitions, update => {
Expand Down
4 changes: 2 additions & 2 deletions code/src/vs/platform/request/node/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { ILogService, ILoggerService } from 'vs/platform/log/common/log';
import { AbstractRequestService, IRequestService } from 'vs/platform/request/common/request';
import { Agent, getProxyAgent } from 'vs/platform/request/node/proxy';
import { createGunzip } from 'zlib';
import { loadSystemCertificates } from '@vscode/proxy-agent';

interface IHTTPConfiguration {
proxy?: string;
Expand Down Expand Up @@ -112,7 +111,8 @@ export class RequestService extends AbstractRequestService implements IRequestSe
}

async loadCertificates(): Promise<string[]> {
return loadSystemCertificates({ log: this.logService });
const proxyAgent = await import('@vscode/proxy-agent');
return proxyAgent.loadSystemCertificates({ log: this.logService });
}
}

Expand Down
26 changes: 7 additions & 19 deletions code/src/vs/workbench/api/browser/mainThreadSCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, DisposableStore, combinedDisposable, dispose, DisposableMap } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, IInputValidation, ISCMViewService, InputValidationType, ISCMActionButtonDescriptor, ISCMInputValueProvider, ISCMInputValueProviderContext } from 'vs/workbench/contrib/scm/common/scm';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, SCMHistoryItemDto, SCMActionButtonDto, SCMHistoryItemGroupDto, SCMInputActionButtonDto } from '../common/extHost.protocol';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, SCMActionButtonDto, SCMHistoryItemGroupDto, SCMInputActionButtonDto } from '../common/extHost.protocol';
import { Command } from 'vs/editor/common/languages';
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { CancellationToken } from 'vs/base/common/cancellation';
Expand All @@ -18,6 +18,7 @@ import { IQuickDiffService, QuickDiffProvider } from 'vs/workbench/contrib/scm/c
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGroup, ISCMHistoryItemGroupDetails, ISCMHistoryItemGroupEntry, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
import { ResourceTree } from 'vs/base/common/resourceTree';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { Codicon } from 'vs/base/common/codicons';

function getSCMInputBoxActionButtonIcon(actionButton: SCMInputActionButtonDto): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (!actionButton.icon) {
Expand All @@ -32,19 +33,6 @@ function getSCMInputBoxActionButtonIcon(actionButton: SCMInputActionButtonDto):
}
}

function getSCMHistoryItemIcon(historyItem: SCMHistoryItemDto): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (!historyItem.icon) {
return undefined;
} else if (URI.isUri(historyItem.icon)) {
return URI.revive(historyItem.icon);
} else if (ThemeIcon.isThemeIcon(historyItem.icon)) {
return historyItem.icon;
} else {
const icon = historyItem.icon as { light: UriComponents; dark: UriComponents };
return { light: URI.revive(icon.light), dark: URI.revive(icon.dark) };
}
}

function getIconFromIconDto(iconDto?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (iconDto === undefined) {
return undefined;
Expand Down Expand Up @@ -184,8 +172,8 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
if (historyItemGroupBase) {
incoming = {
id: historyItemGroupBase.id,
label: `$(cloud-download) ${historyItemGroupBase.label}`,
// description: localize('incoming', "Incoming Changes"),
label: historyItemGroupBase.label,
icon: Codicon.cloudDownload,
ancestor: ancestor?.id,
count: ancestor?.behind ?? 0,
};
Expand All @@ -194,8 +182,8 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
// Outgoing
const outgoing: ISCMHistoryItemGroupEntry = {
id: historyItemGroup.id,
label: `$(cloud-upload) ${historyItemGroup.label}`,
// description: localize('outgoing', "Outgoing Changes"),
label: historyItemGroup.label,
icon: Codicon.cloudUpload,
ancestor: ancestor?.id,
count: ancestor?.ahead ?? 0,
};
Expand All @@ -213,7 +201,7 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {

async provideHistoryItems(historyItemGroupId: string, options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined> {
const historyItems = await this.proxy.$provideHistoryItems(this.handle, historyItemGroupId, options, CancellationToken.None);
return historyItems?.map(historyItem => ({ ...historyItem, icon: getSCMHistoryItemIcon(historyItem), }));
return historyItems?.map(historyItem => ({ ...historyItem, icon: getIconFromIconDto(historyItem.icon) }));
}

async provideHistoryItemChanges(historyItemId: string): Promise<ISCMHistoryItemChange[] | undefined> {
Expand Down
8 changes: 7 additions & 1 deletion code/src/vs/workbench/browser/parts/editor/editorParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { EditorGroupLayout, GroupDirection, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, IEditorDropTargetDelegate, IEditorGroupsService, IEditorSideGroup, IFindGroupScope, IMergeGroupOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
import { EditorGroupLayout, GroupDirection, GroupLocation, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, IEditorDropTargetDelegate, IEditorGroupsService, IEditorSideGroup, IFindGroupScope, IMergeGroupOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
import { Event, Emitter } from 'vs/base/common/event';
import { getActiveDocument } from 'vs/base/browser/dom';
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -306,6 +306,12 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd
}

findGroup(scope: IFindGroupScope, source?: IEditorGroupView | GroupIdentifier, wrap?: boolean): IEditorGroupView | undefined {
if (scope.location === GroupLocation.FIRST || scope.location === GroupLocation.LAST) {
// TODO implement support for all scopes with multiple editor parts
// https://github.com/microsoft/vscode/issues/198651
return scope.location === GroupLocation.FIRST ? this.groups[0] : this.groups[this.groups.length - 1];
}

if (source) {
return this.getPart(source).findGroup(scope, source, wrap);
}
Expand Down
Loading

0 comments on commit 61ab6ee

Please sign in to comment.