mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
Merge branch 'ads-master-vscode-2020-04-08T06-33-35'
This commit is contained in:
@@ -64,6 +64,12 @@ const nodeCachedDataDir = getNodeCachedDir();
|
||||
// Configure static command line arguments
|
||||
const argvConfig = configureCommandlineSwitchesSync(args);
|
||||
|
||||
// Remove env set by snap https://github.com/microsoft/vscode/issues/85344
|
||||
if (process.env['SNAP']) {
|
||||
delete process.env['GDK_PIXBUF_MODULE_FILE'];
|
||||
delete process.env['GDK_PIXBUF_MODULEDIR'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Support user defined locale: load it early before app('ready')
|
||||
* to have more things running in parallel.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INextIterator } from 'vs/base/common/iterator';
|
||||
import { INavigator } from 'vs/base/common/navigator';
|
||||
|
||||
export interface IView {
|
||||
id?: string;
|
||||
@@ -31,7 +31,7 @@ export class HeightMap {
|
||||
return !last ? 0 : last.top + last.height;
|
||||
}
|
||||
|
||||
public onInsertItems(iterator: INextIterator<IViewItem>, afterItemId: string | null = null): number | undefined {
|
||||
public onInsertItems(iterator: INavigator<IViewItem>, afterItemId: string | null = null): number | undefined {
|
||||
let viewItem: IViewItem | null = null;
|
||||
let i: number, j: number;
|
||||
let totalSize: number;
|
||||
@@ -89,7 +89,7 @@ export class HeightMap {
|
||||
}
|
||||
|
||||
// Contiguous items
|
||||
public onRemoveItems(iterator: INextIterator<string>): void {
|
||||
public onRemoveItems(iterator: INavigator<string>): void {
|
||||
let itemId: string | null = null;
|
||||
let viewItem: IViewItem;
|
||||
let startIndex: number | null = null;
|
||||
|
||||
@@ -14,7 +14,7 @@ import { clamp } from 'vs/base/common/numbers';
|
||||
import { range, firstIndex, pushToStart } from 'vs/base/common/arrays';
|
||||
import { Sash, Orientation, ISashEvent as IBaseSashEvent } from 'vs/base/browser/ui/sash/sash';
|
||||
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { ArrayIterator } from 'vs/base/common/iterator';
|
||||
import { ArrayNavigator } from 'vs/base/common/navigator';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { ISplitViewStyles, Sizing } from 'vs/base/browser/ui/splitview/splitview';
|
||||
@@ -239,7 +239,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable {
|
||||
if (container.parentElement) {
|
||||
this.viewContainer.removeChild(container);
|
||||
}
|
||||
this.onRemoveItems(new ArrayIterator([item.view.id!]));
|
||||
this.onRemoveItems(new ArrayNavigator([item.view.id!]));
|
||||
});
|
||||
const disposable = combinedDisposable(onChangeDisposable, containerDisposable);
|
||||
|
||||
@@ -268,7 +268,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable {
|
||||
const item: IViewItem = { onAdd, onRemove, view, container, size: viewSize, layout, disposable, height: viewSize, top: 0, width: 0 };
|
||||
this.viewItems.splice(currentIndex, 0, item);
|
||||
|
||||
this.onInsertItems(new ArrayIterator([item]), currentIndex > 0 ? this.viewItems[currentIndex - 1].view.id : undefined);
|
||||
this.onInsertItems(new ArrayNavigator([item]), currentIndex > 0 ? this.viewItems[currentIndex - 1].view.id : undefined);
|
||||
|
||||
// Add sash
|
||||
if (this.options.enableResizing && this.viewItems.length > 1) {
|
||||
@@ -342,7 +342,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable {
|
||||
if (container.parentElement) {
|
||||
this.viewContainer.removeChild(container);
|
||||
}
|
||||
this.onRemoveItems(new ArrayIterator([item.view.id!]));
|
||||
this.onRemoveItems(new ArrayNavigator([item.view.id!]));
|
||||
});
|
||||
const disposable = combinedDisposable(onChangeDisposable, containerDisposable);
|
||||
|
||||
@@ -371,7 +371,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable {
|
||||
const item: IViewItem = { onAdd, onRemove, view, container, size: viewSize, layout, disposable, height: viewSize, top: 0, width: 0 };
|
||||
this.viewItems.splice(index, 0, item);
|
||||
|
||||
this.onInsertItems(new ArrayIterator([item]), index > 0 ? this.viewItems[index - 1].view.id : undefined);
|
||||
this.onInsertItems(new ArrayNavigator([item]), index > 0 ? this.viewItems[index - 1].view.id : undefined);
|
||||
|
||||
// Add sash
|
||||
if (this.options.enableResizing && this.viewItems.length > 1) {
|
||||
|
||||
23
src/sql/base/common/navigator.ts
Normal file
23
src/sql/base/common/navigator.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INavigator as vsINavigator } from 'vs/base/common/navigator';
|
||||
|
||||
export interface INavigator<T> extends vsINavigator<T> {
|
||||
parent(): T | null;
|
||||
}
|
||||
|
||||
export class MappedNavigator<T, R> implements INavigator<R> {
|
||||
|
||||
constructor(protected navigator: INavigator<T>, private fn: (item: T | null) => R) {
|
||||
}
|
||||
|
||||
current() { return this.fn(this.navigator.current()); }
|
||||
previous() { return this.fn(this.navigator.previous()); }
|
||||
first() { return this.fn(this.navigator.first()); }
|
||||
last() { return this.fn(this.navigator.last()); }
|
||||
next() { return this.fn(this.navigator.next()); }
|
||||
parent() { return this.fn(this.navigator.parent()); }
|
||||
}
|
||||
@@ -20,7 +20,7 @@ export class AzdataNodeModuleFactory implements INodeModuleFactory {
|
||||
|
||||
constructor(
|
||||
private readonly _apiFactory: IAzdataExtensionApiFactory,
|
||||
private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>,
|
||||
private readonly _extensionPaths: TernarySearchTree<string, IExtensionDescription>,
|
||||
private readonly _logService: ILogService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectio
|
||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
@@ -29,6 +29,8 @@ import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
const connectAuthority = 'connect';
|
||||
|
||||
@@ -48,7 +50,7 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution,
|
||||
constructor(
|
||||
@ICapabilitiesService private readonly _capabilitiesService: ICapabilitiesService,
|
||||
@IConnectionManagementService private readonly _connectionManagementService: IConnectionManagementService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IEnvironmentService environmentService: INativeEnvironmentService,
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { CommandLineWorkbenchContribution } from 'sql/workbench/contrib/commandLine/electron-browser/commandLine';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/media/icons/common-icons';
|
||||
import 'vs/css!./dashboardWidgetWrapper';
|
||||
|
||||
import {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./dashboardPage';
|
||||
import 'vs/css!sql/media/icons/common-icons';
|
||||
import 'sql/workbench/contrib/dashboard/browser/core/dashboardPanelStyles';
|
||||
|
||||
import { Component, Inject, forwardRef, ViewChild, ElementRef, ViewChildren, QueryList, ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/media/icons/common-icons';
|
||||
import 'vs/css!./media/explorerWidget';
|
||||
|
||||
import { Component, Inject, forwardRef, OnInit, ViewChild, ElementRef, ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/media/actionBarLabel';
|
||||
import 'vs/css!./media/dataExplorer.contribution';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ICellModel, INotebookModel } from 'sql/workbench/services/notebook/brow
|
||||
import { INotebookFindModel } from 'sql/workbench/contrib/notebook/browser/models/notebookFindModel';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { NotebookFindMatch, NotebookFindDecorations } from 'sql/workbench/contrib/notebook/find/notebookFindDecorations';
|
||||
import { NotebookFindMatch, NotebookFindDecorations } from 'sql/workbench/contrib/notebook/browser/find/notebookFindDecorations';
|
||||
import * as model from 'vs/editor/common/model';
|
||||
import { ModelDecorationOptions, DidChangeDecorationsEmitter, createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { IModelDecorationsChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IModelDecorationsChangeAccessor } from 'vs/editor/common/model';
|
||||
import { NotebookFindMatch } from 'sql/workbench/contrib/notebook/find/notebookFindDecorations';
|
||||
import { NotebookFindMatch } from 'sql/workbench/contrib/notebook/browser/find/notebookFindDecorations';
|
||||
import { NotebookRange } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
|
||||
export interface INotebookFindModel {
|
||||
|
||||
@@ -31,7 +31,7 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/find/notebookFindModel';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/browser/find/notebookFindModel';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { CellType } from 'sql/workbench/services/notebook/common/contracts';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||
import { IFindNotebookController } from 'sql/workbench/contrib/notebook/find/notebookFindWidget';
|
||||
import { IFindNotebookController } from 'sql/workbench/contrib/notebook/browser/find/notebookFindWidget';
|
||||
import { INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { TreeUpdateUtils } from 'sql/workbench/services/objectExplorer/browser/treeUpdateUtils';
|
||||
|
||||
@@ -16,7 +16,7 @@ import { NotebookModule } from 'sql/workbench/contrib/notebook/browser/notebook.
|
||||
import { NOTEBOOK_SELECTOR } from 'sql/workbench/contrib/notebook/browser/notebook.component';
|
||||
import { INotebookParams, INotebookService, NotebookRange } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ACTION_IDS, NOTEBOOK_MAX_MATCHES, IFindNotebookController, FindWidget, IConfigurationChangedEvent } from 'sql/workbench/contrib/notebook/find/notebookFindWidget';
|
||||
import { ACTION_IDS, NOTEBOOK_MAX_MATCHES, IFindNotebookController, FindWidget, IConfigurationChangedEvent } from 'sql/workbench/contrib/notebook/browser/find/notebookFindWidget';
|
||||
import { IOverlayWidget } from 'vs/editor/browser/editorBrowser';
|
||||
import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState';
|
||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||
@@ -30,7 +30,7 @@ import { INotebookModel } from 'sql/workbench/services/notebook/browser/models/m
|
||||
import { INotebookFindModel } from 'sql/workbench/contrib/notebook/browser/models/notebookFindModel';
|
||||
import { IDisposable, DisposableStore, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IModelDecorationsChangeAccessor, IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
import { NotebookFindDecorations } from 'sql/workbench/contrib/notebook/find/notebookFindDecorations';
|
||||
import { NotebookFindDecorations } from 'sql/workbench/contrib/notebook/browser/find/notebookFindDecorations';
|
||||
import { TimeoutTimer } from 'vs/base/common/async';
|
||||
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!../cellViews/textCell';
|
||||
import 'vs/css!../cellViews/media/markdown';
|
||||
import 'vs/css!../cellViews/media/highlight';
|
||||
|
||||
import { OnInit, Component, Input, Inject, ElementRef, ViewChild } from '@angular/core';
|
||||
import { AngularDisposable } from 'sql/base/browser/lifecycle';
|
||||
import { IMimeComponent } from 'sql/workbench/contrib/notebook/browser/outputs/mimeRegistry';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { CellTypes } from 'sql/workbench/services/notebook/common/contracts';
|
||||
import { IClientSession, INotebookModelOptions } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/find/notebookFindModel';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/browser/find/notebookFindModel';
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { ModelFactory } from 'sql/workbench/services/notebook/browser/models/modelFactory';
|
||||
|
||||
@@ -12,10 +12,10 @@ import { INotebookManager, INotebookService, INotebookEditor, ILanguageMagic, IN
|
||||
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IStandardKernelWithProvider } from 'sql/workbench/services/notebook/browser/models/notebookUtils';
|
||||
import { IModelDecorationsChangeAccessor } from 'vs/editor/common/model';
|
||||
import { NotebookFindMatch } from 'sql/workbench/contrib/notebook/find/notebookFindDecorations';
|
||||
import { URI } from 'vs/workbench/workbench.web.api';
|
||||
import { NotebookFindMatch } from 'sql/workbench/contrib/notebook/browser/find/notebookFindDecorations';
|
||||
import { RenderMimeRegistry } from 'sql/workbench/services/notebook/browser/outputs/registry';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export class NotebookModelStub implements INotebookModel {
|
||||
constructor(private _languageInfo?: nb.ILanguageInfo) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import { INavigator } from 'sql/base/common/navigator';
|
||||
import { ITree, IHighlightEvent, ISelectionEvent, IFocusEvent, ITreeStyles } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IItemExpandEvent, IItemCollapseEvent } from 'vs/base/parts/tree/browser/treeModel';
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import { localize } from 'vs/nls';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { Table } from 'sql/base/browser/ui/table/table';
|
||||
import { QueryEditor } from './queryEditor';
|
||||
import { CellSelectionModel } from 'sql/base/browser/ui/table/plugins/cellSelectionModel.plugin';
|
||||
@@ -23,6 +22,7 @@ import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { SaveFormat } from 'sql/workbench/services/query/common/resultSerializer';
|
||||
import { IExtensionRecommendationsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
|
||||
export interface IGridActionContext {
|
||||
gridDataProvider: IGridDataProvider;
|
||||
@@ -212,7 +212,7 @@ export class ChartDataAction extends Action {
|
||||
|
||||
constructor(
|
||||
@IEditorService private editorService: IEditorService,
|
||||
@IExtensionTipsService private readonly extensionTipsService: IExtensionTipsService
|
||||
@IExtensionRecommendationsService private readonly extensionTipsService: IExtensionRecommendationsService
|
||||
) {
|
||||
super(ChartDataAction.ID, ChartDataAction.LABEL, ChartDataAction.ICON);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/media/overwriteVsIcons';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/media/icons/common-icons';
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { Modal } from 'sql/workbench/browser/modal/modal';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
|
||||
@@ -24,7 +24,7 @@ import { Schemas } from 'vs/base/common/network';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { getInstalledExtensions, IExtensionStatus, onExtensionChanged, isKeymapExtension } from 'vs/workbench/contrib/extensions/common/extensionsUtils';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionRecommendationsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { splitName } from 'vs/base/common/labels';
|
||||
@@ -204,7 +204,7 @@ class WelcomePage extends Disposable {
|
||||
@IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
|
||||
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
|
||||
@IExtensionTipsService private readonly tipsService: IExtensionTipsService,
|
||||
@IExtensionRecommendationsService private readonly tipsService: IExtensionRecommendationsService,
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
|
||||
@@ -179,9 +179,8 @@ suite('Insights Utils tests', function () {
|
||||
const environmentService = new MockWorkbenchEnvironmentService({ TEST_PATH: queryFileDir });
|
||||
|
||||
// Create mock window service with env variable containing test folder for resolution
|
||||
const configurationResolverService = new TestConfigurationResolverService(environmentService.userEnv,
|
||||
const configurationResolverService = new TestConfigurationResolverService({ getExecPath: () => undefined }, environmentService.userEnv,
|
||||
undefined,
|
||||
environmentService,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
@@ -209,9 +208,8 @@ suite('Insights Utils tests', function () {
|
||||
const environmentService = new MockWorkbenchEnvironmentService({ TEST_PATH: queryFileDir });
|
||||
|
||||
// Create mock window service with env variable containing test folder for resolution
|
||||
const configurationResolverService = new TestConfigurationResolverService(environmentService.userEnv,
|
||||
const configurationResolverService = new TestConfigurationResolverService({ getExecPath: () => undefined }, environmentService.userEnv,
|
||||
undefined,
|
||||
environmentService,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
|
||||
@@ -12,7 +12,6 @@ import { TreeNode, TreeItemCollapsibleState } from 'sql/workbench/services/objec
|
||||
import * as azdata from 'azdata';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
@@ -21,6 +20,7 @@ import { TestConnectionManagementService } from 'sql/platform/connection/test/co
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
suite('SQL Object Explorer Service tests', () => {
|
||||
let sqlOEProvider: TypeMoq.Mock<TestObjectExplorerProvider>;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as azdata from 'azdata';
|
||||
import * as assert from 'assert';
|
||||
import { RestoreViewModel } from 'sql/workbench/services/restore/browser/restoreViewModel';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ServiceOptionType } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
suite('Restore Dialog view model tests', () => {
|
||||
let option1String = 'option1';
|
||||
|
||||
@@ -51,6 +51,8 @@ export const BrowserFeatures = {
|
||||
return KeyboardSupport.None;
|
||||
})(),
|
||||
|
||||
touch: 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0,
|
||||
pointerEvents: window.PointerEvent && ('ontouchstart' in window || window.navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0)
|
||||
// 'ontouchstart' in window always evaluates to true with typescript's modern typings. This causes `window` to be
|
||||
// `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
|
||||
touch: 'ontouchstart' in window || navigator.maxTouchPoints > 0 || (window as Window).navigator.msMaxTouchPoints > 0,
|
||||
pointerEvents: window.PointerEvent && ('ontouchstart' in window || (window as Window).navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0 || (window as Window).navigator.msMaxTouchPoints > 0)
|
||||
};
|
||||
|
||||
@@ -131,7 +131,9 @@ export class Gesture extends Disposable {
|
||||
|
||||
@memoize
|
||||
private static isTouchDevice(): boolean {
|
||||
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0;
|
||||
// `'ontouchstart' in window` always evaluates to true with typescript's modern typings. This causes `window` to be
|
||||
// `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
|
||||
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || (window as Window).navigator.msMaxTouchPoints > 0;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -1041,9 +1041,10 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
|
||||
// Util
|
||||
|
||||
private getItemIndexFromEventTarget(target: EventTarget | null): number | undefined {
|
||||
const scrollableElement = this.scrollableElement.getDomNode();
|
||||
let element: HTMLElement | null = target as (HTMLElement | null);
|
||||
|
||||
while (element instanceof HTMLElement && element !== this.rowsContainer) {
|
||||
while (element instanceof HTMLElement && element !== this.rowsContainer && scrollableElement.contains(element)) {
|
||||
const rawIndex = element.getAttribute('data-index');
|
||||
|
||||
if (rawIndex) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle'
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { timeout, CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
|
||||
import { isPromiseCanceledError, onUnexpectedError } from 'vs/base/common/errors';
|
||||
@@ -313,7 +313,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
|
||||
private readonly collapseByDefault?: { (e: T): boolean; };
|
||||
|
||||
private readonly subTreeRefreshPromises = new Map<IAsyncDataTreeNode<TInput, T>, Promise<void>>();
|
||||
private readonly refreshPromises = new Map<IAsyncDataTreeNode<TInput, T>, CancelablePromise<T[]>>();
|
||||
private readonly refreshPromises = new Map<IAsyncDataTreeNode<TInput, T>, CancelablePromise<Iterable<T>>>();
|
||||
|
||||
protected readonly identityProvider?: IIdentityProvider<T>;
|
||||
private readonly autoExpandSingleChildren: boolean;
|
||||
@@ -740,10 +740,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
|
||||
private async doRefreshNode(node: IAsyncDataTreeNode<TInput, T>, recursive: boolean, viewStateContext?: IAsyncDataTreeViewStateContext<TInput, T>): Promise<IAsyncDataTreeNode<TInput, T>[]> {
|
||||
node.hasChildren = !!this.dataSource.hasChildren(node.element!);
|
||||
|
||||
let childrenPromise: Promise<T[]>;
|
||||
let childrenPromise: Promise<Iterable<T>>;
|
||||
|
||||
if (!node.hasChildren) {
|
||||
childrenPromise = Promise.resolve([]);
|
||||
childrenPromise = Promise.resolve(Iterable.empty());
|
||||
} else {
|
||||
const slowTimeout = timeout(800);
|
||||
|
||||
@@ -777,7 +777,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private doGetChildren(node: IAsyncDataTreeNode<TInput, T>): Promise<T[]> {
|
||||
private doGetChildren(node: IAsyncDataTreeNode<TInput, T>): Promise<Iterable<T>> {
|
||||
let result = this.refreshPromises.get(node);
|
||||
|
||||
if (result) {
|
||||
@@ -809,7 +809,9 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private setChildren(node: IAsyncDataTreeNode<TInput, T>, childrenElements: T[], recursive: boolean, viewStateContext?: IAsyncDataTreeViewStateContext<TInput, T>): IAsyncDataTreeNode<TInput, T>[] {
|
||||
private setChildren(node: IAsyncDataTreeNode<TInput, T>, childrenElementsIterable: Iterable<T>, recursive: boolean, viewStateContext?: IAsyncDataTreeViewStateContext<TInput, T>): IAsyncDataTreeNode<TInput, T>[] {
|
||||
const childrenElements = [...childrenElementsIterable];
|
||||
|
||||
// perf: if the node was and still is a leaf, avoid all this hassle
|
||||
if (node.children.length === 0 && childrenElements.length === 0) {
|
||||
return [];
|
||||
@@ -943,15 +945,15 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
|
||||
|
||||
return {
|
||||
element: node,
|
||||
children: node.hasChildren ? Iterator.map(Iterator.fromArray(node.children), child => this.asTreeElement(child, viewStateContext)) : [],
|
||||
children: node.hasChildren ? Iterable.map(node.children, child => this.asTreeElement(child, viewStateContext)) : [],
|
||||
collapsible: node.hasChildren,
|
||||
collapsed
|
||||
};
|
||||
}
|
||||
|
||||
protected processChildren(children: T[]): T[] {
|
||||
protected processChildren(children: Iterable<T>): Iterable<T> {
|
||||
if (this.sorter) {
|
||||
children.sort(this.sorter.compare.bind(this.sorter));
|
||||
children = [...children].sort(this.sorter.compare.bind(this.sorter));
|
||||
}
|
||||
|
||||
return children;
|
||||
@@ -1243,9 +1245,9 @@ export class CompressibleAsyncDataTree<TInput, T, TFilterData = void> extends As
|
||||
// For compressed async data trees, `TreeVisibility.Recurse` doesn't currently work
|
||||
// and we have to filter everything beforehand
|
||||
// Related to #85193 and #85835
|
||||
protected processChildren(children: T[]): T[] {
|
||||
protected processChildren(children: Iterable<T>): Iterable<T> {
|
||||
if (this.filter) {
|
||||
children = children.filter(e => {
|
||||
children = Iterable.filter(children, e => {
|
||||
const result = this.filter!.filter(e, TreeVisibility.Visible);
|
||||
const visibility = getVisibility(result);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { Iterator, ISequence } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ITreeModel, ITreeNode, ITreeElement, ICollapseStateChangeEvent, ITreeModelSpliceEvent, TreeError, TreeFilterResult, TreeVisibility, WeakMapper } from 'vs/base/browser/ui/tree/tree';
|
||||
import { IObjectTreeModelOptions, ObjectTreeModel, IObjectTreeModel } from 'vs/base/browser/ui/tree/objectTreeModel';
|
||||
|
||||
// Exported only for test reasons, do not use directly
|
||||
export interface ICompressedTreeElement<T> extends ITreeElement<T> {
|
||||
readonly children?: ISequence<ICompressedTreeElement<T>>;
|
||||
readonly children?: Iterable<ICompressedTreeElement<T>>;
|
||||
readonly incompressible?: boolean;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ function noCompress<T>(element: ICompressedTreeElement<T>): ITreeElement<ICompre
|
||||
|
||||
return {
|
||||
element: { elements, incompressible },
|
||||
children: Iterator.map(Iterator.from(element.children), noCompress),
|
||||
children: Iterable.map(Iterable.from(element.children), noCompress),
|
||||
collapsible: element.collapsible,
|
||||
collapsed: element.collapsed
|
||||
};
|
||||
@@ -38,12 +38,11 @@ export function compress<T>(element: ICompressedTreeElement<T>): ITreeElement<IC
|
||||
const elements = [element.element];
|
||||
const incompressible = element.incompressible || false;
|
||||
|
||||
let childrenIterator: Iterator<ITreeElement<T>>;
|
||||
let childrenIterator: Iterable<ITreeElement<T>>;
|
||||
let children: ITreeElement<T>[];
|
||||
|
||||
while (true) {
|
||||
childrenIterator = Iterator.from(element.children);
|
||||
children = Iterator.collect(childrenIterator, 2);
|
||||
[children, childrenIterator] = Iterable.consume(Iterable.from(element.children), 2);
|
||||
|
||||
if (children.length !== 1) {
|
||||
break;
|
||||
@@ -60,19 +59,19 @@ export function compress<T>(element: ICompressedTreeElement<T>): ITreeElement<IC
|
||||
|
||||
return {
|
||||
element: { elements, incompressible },
|
||||
children: Iterator.map(Iterator.concat(Iterator.fromArray(children), childrenIterator), compress),
|
||||
children: Iterable.map(Iterable.concat(children, childrenIterator), compress),
|
||||
collapsible: element.collapsible,
|
||||
collapsed: element.collapsed
|
||||
};
|
||||
}
|
||||
|
||||
function _decompress<T>(element: ITreeElement<ICompressedTreeNode<T>>, index = 0): ICompressedTreeElement<T> {
|
||||
let children: Iterator<ICompressedTreeElement<T>>;
|
||||
let children: Iterable<ICompressedTreeElement<T>>;
|
||||
|
||||
if (index < element.element.elements.length - 1) {
|
||||
children = Iterator.single(_decompress(element, index + 1));
|
||||
children = [_decompress(element, index + 1)];
|
||||
} else {
|
||||
children = Iterator.map(Iterator.from(element.children), el => _decompress(el, 0));
|
||||
children = Iterable.map(Iterable.from(element.children), el => _decompress(el, 0));
|
||||
}
|
||||
|
||||
if (index === 0 && element.element.incompressible) {
|
||||
@@ -98,12 +97,12 @@ export function decompress<T>(element: ITreeElement<ICompressedTreeNode<T>>): IC
|
||||
return _decompress(element, 0);
|
||||
}
|
||||
|
||||
function splice<T>(treeElement: ICompressedTreeElement<T>, element: T, children: Iterator<ICompressedTreeElement<T>>): ICompressedTreeElement<T> {
|
||||
function splice<T>(treeElement: ICompressedTreeElement<T>, element: T, children: Iterable<ICompressedTreeElement<T>>): ICompressedTreeElement<T> {
|
||||
if (treeElement.element === element) {
|
||||
return { ...treeElement, children };
|
||||
}
|
||||
|
||||
return { ...treeElement, children: Iterator.map(Iterator.from(treeElement.children), e => splice(e, element, children)) };
|
||||
return { ...treeElement, children: Iterable.map(Iterable.from(treeElement.children), e => splice(e, element, children)) };
|
||||
}
|
||||
|
||||
interface ICompressedObjectTreeModelOptions<T, TFilterData> extends IObjectTreeModelOptions<ICompressedTreeNode<T>, TFilterData> {
|
||||
@@ -136,10 +135,10 @@ export class CompressedObjectTreeModel<T extends NonNullable<any>, TFilterData e
|
||||
|
||||
setChildren(
|
||||
element: T | null,
|
||||
children: ISequence<ICompressedTreeElement<T>> | undefined
|
||||
children: Iterable<ICompressedTreeElement<T>> = Iterable.empty()
|
||||
): void {
|
||||
if (element === null) {
|
||||
const compressedChildren = Iterator.map(Iterator.from(children), this.enabled ? compress : noCompress);
|
||||
const compressedChildren = Iterable.map(children, this.enabled ? compress : noCompress);
|
||||
this._setChildren(null, compressedChildren);
|
||||
return;
|
||||
}
|
||||
@@ -155,7 +154,7 @@ export class CompressedObjectTreeModel<T extends NonNullable<any>, TFilterData e
|
||||
const parent = this.model.getNode(compressedParentNode) as ITreeNode<ICompressedTreeNode<T>, TFilterData>;
|
||||
|
||||
const decompressedElement = decompress(node);
|
||||
const splicedElement = splice(decompressedElement, element, Iterator.from(children));
|
||||
const splicedElement = splice(decompressedElement, element, children);
|
||||
const recompressedElement = (this.enabled ? compress : noCompress)(splicedElement);
|
||||
|
||||
const parentChildren = parent.children
|
||||
@@ -176,15 +175,15 @@ export class CompressedObjectTreeModel<T extends NonNullable<any>, TFilterData e
|
||||
this.enabled = enabled;
|
||||
|
||||
const root = this.model.getNode();
|
||||
const rootChildren = Iterator.from((root.children as unknown) as ITreeNode<ICompressedTreeNode<T>>[]); // {{SQL CARBON EDIT}} strict-null-checks
|
||||
const decompressedRootChildren = Iterator.map(rootChildren, decompress);
|
||||
const recompressedRootChildren = Iterator.map(decompressedRootChildren, enabled ? compress : noCompress);
|
||||
const rootChildren = root.children as ITreeNode<ICompressedTreeNode<T>>[];
|
||||
const decompressedRootChildren = Iterable.map(rootChildren, decompress);
|
||||
const recompressedRootChildren = Iterable.map(decompressedRootChildren, enabled ? compress : noCompress);
|
||||
this._setChildren(null, recompressedRootChildren);
|
||||
}
|
||||
|
||||
private _setChildren(
|
||||
node: ICompressedTreeNode<T> | null,
|
||||
children: ISequence<ITreeElement<ICompressedTreeNode<T>>> | undefined
|
||||
children: Iterable<ITreeElement<ICompressedTreeNode<T>>>
|
||||
): void {
|
||||
const insertedElements = new Set<T | null>();
|
||||
const _onDidCreateNode = (node: ITreeNode<ICompressedTreeNode<T>, TFilterData>) => {
|
||||
@@ -413,7 +412,7 @@ export class CompressibleObjectTreeModel<T extends NonNullable<any>, TFilterData
|
||||
this.model = new CompressedObjectTreeModel(user, mapList(this.nodeMapper, list), mapOptions(compressedNodeUnwrapper, options));
|
||||
}
|
||||
|
||||
setChildren(element: T | null, children?: ISequence<ICompressedTreeElement<T>>): void {
|
||||
setChildren(element: T | null, children: Iterable<ICompressedTreeElement<T>> = Iterable.empty()): void {
|
||||
this.model.setChildren(element, children);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { ITreeNode, ITreeModel, ITreeElement, ITreeRenderer, ITreeSorter, IDataSource, TreeError } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ObjectTreeModel } from 'vs/base/browser/ui/tree/objectTreeModel';
|
||||
import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list/list';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
|
||||
export interface IDataTreeOptions<T, TFilterData = void> extends IAbstractTreeOptions<T, TFilterData> {
|
||||
readonly sorter?: ITreeSorter<T>;
|
||||
@@ -158,9 +158,9 @@ export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | nu
|
||||
this.model.setChildren((element === this.input ? null : element) as T, this.iterate(element, isCollapsed).elements, onDidCreateNode, onDidDeleteNode);
|
||||
}
|
||||
|
||||
private iterate(element: TInput | T, isCollapsed?: (el: T) => boolean | undefined): { elements: Iterator<ITreeElement<T>>, size: number } {
|
||||
const children = this.dataSource.getChildren(element);
|
||||
const elements = Iterator.map<any, ITreeElement<T>>(Iterator.fromArray(children), element => {
|
||||
private iterate(element: TInput | T, isCollapsed?: (el: T) => boolean | undefined): { elements: Iterable<ITreeElement<T>>, size: number } {
|
||||
const children = [...this.dataSource.getChildren(element)];
|
||||
const elements = Iterable.map(children, element => {
|
||||
const { elements: children, size } = this.iterate(element, isCollapsed);
|
||||
const collapsible = this.dataSource.hasChildren ? this.dataSource.hasChildren(element) : undefined;
|
||||
const collapsed = size === 0 ? undefined : (isCollapsed && isCollapsed(element));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/tree';
|
||||
import { Iterator, ISequence } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { AbstractTree, IAbstractTreeOptions } from 'vs/base/browser/ui/tree/abstractTree';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { IndexTreeModel } from 'vs/base/browser/ui/tree/indexTreeModel';
|
||||
@@ -28,7 +28,7 @@ export class IndexTree<T, TFilterData = void> extends AbstractTree<T, TFilterDat
|
||||
super(user, container, delegate, renderers, options);
|
||||
}
|
||||
|
||||
splice(location: number[], deleteCount: number, toInsert: ISequence<ITreeElement<T>> = Iterator.empty()): void {
|
||||
splice(location: number[], deleteCount: number, toInsert: Iterable<ITreeElement<T>> = Iterable.empty()): void {
|
||||
this.model.splice(location, deleteCount, toInsert);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { ICollapseStateChangeEvent, ITreeElement, ITreeFilter, ITreeFilterDataResult, ITreeModel, ITreeNode, TreeVisibility, ITreeModelSpliceEvent, TreeError } from 'vs/base/browser/ui/tree/tree';
|
||||
import { tail2 } from 'vs/base/common/arrays';
|
||||
import { Emitter, Event, EventBufferer } from 'vs/base/common/event';
|
||||
import { ISequence, Iterator } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
|
||||
// Exported for tests
|
||||
@@ -103,7 +103,7 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
|
||||
splice(
|
||||
location: number[],
|
||||
deleteCount: number,
|
||||
toInsert?: ISequence<ITreeElement<T>>,
|
||||
toInsert: Iterable<ITreeElement<T>> = Iterable.empty(),
|
||||
onDidCreateNode?: (node: ITreeNode<T, TFilterData>) => void,
|
||||
onDidDeleteNode?: (node: ITreeNode<T, TFilterData>) => void
|
||||
): void {
|
||||
@@ -113,7 +113,7 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
|
||||
|
||||
const { parentNode, listIndex, revealed, visible } = this.getParentNodeWithListIndex(location);
|
||||
const treeListElementsToInsert: ITreeNode<T, TFilterData>[] = [];
|
||||
const nodesToInsertIterator = Iterator.map(Iterator.from(toInsert), el => this.createTreeNode(el, parentNode, parentNode.visible ? TreeVisibility.Visible : TreeVisibility.Hidden, revealed, treeListElementsToInsert, onDidCreateNode));
|
||||
const nodesToInsertIterator = Iterable.map(toInsert, el => this.createTreeNode(el, parentNode, parentNode.visible ? TreeVisibility.Visible : TreeVisibility.Hidden, revealed, treeListElementsToInsert, onDidCreateNode));
|
||||
|
||||
const lastIndex = location[location.length - 1];
|
||||
|
||||
@@ -134,14 +134,14 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
|
||||
let insertedVisibleChildrenCount = 0;
|
||||
let renderNodeCount = 0;
|
||||
|
||||
Iterator.forEach(nodesToInsertIterator, child => {
|
||||
for (const child of nodesToInsertIterator) {
|
||||
nodesToInsert.push(child);
|
||||
renderNodeCount += child.renderNodeCount;
|
||||
|
||||
if (child.visible) {
|
||||
child.visibleChildIndex = visibleChildStartIndex + insertedVisibleChildrenCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const deletedNodes = parentNode.children.splice(lastIndex, deleteCount, ...nodesToInsert);
|
||||
|
||||
@@ -365,21 +365,21 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
|
||||
treeListElements.push(node);
|
||||
}
|
||||
|
||||
const childElements = Iterator.from(treeElement.children);
|
||||
const childElements = treeElement.children || Iterable.empty();
|
||||
const childRevealed = revealed && visibility !== TreeVisibility.Hidden && !node.collapsed;
|
||||
const childNodes = Iterator.map(childElements, el => this.createTreeNode(el, node, visibility, childRevealed, treeListElements, onDidCreateNode));
|
||||
const childNodes = Iterable.map(childElements, el => this.createTreeNode(el, node, visibility, childRevealed, treeListElements, onDidCreateNode));
|
||||
|
||||
let visibleChildrenCount = 0;
|
||||
let renderNodeCount = 1;
|
||||
|
||||
Iterator.forEach(childNodes, child => {
|
||||
for (const child of childNodes) {
|
||||
node.children.push(child);
|
||||
renderNodeCount += child.renderNodeCount;
|
||||
|
||||
if (child.visible) {
|
||||
child.visibleChildIndex = visibleChildrenCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
node.collapsible = node.collapsible || node.children.length > 0;
|
||||
node.visibleChildrenCount = visibleChildrenCount;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ISequence } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { AbstractTree, IAbstractTreeOptions, IAbstractTreeOptionsUpdate } from 'vs/base/browser/ui/tree/abstractTree';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { ITreeNode, ITreeModel, ITreeElement, ITreeRenderer, ITreeSorter, ICollapseStateChangeEvent } from 'vs/base/browser/ui/tree/tree';
|
||||
@@ -33,7 +33,7 @@ export class ObjectTree<T extends NonNullable<any>, TFilterData = void> extends
|
||||
super(user, container, delegate, renderers, options as IObjectTreeOptions<T | null, TFilterData>);
|
||||
}
|
||||
|
||||
setChildren(element: T | null, children?: ISequence<ITreeElement<T>>): void {
|
||||
setChildren(element: T | null, children: Iterable<ITreeElement<T>> = Iterable.empty()): void {
|
||||
this.model.setChildren(element, children);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ export class CompressibleObjectTree<T extends NonNullable<any>, TFilterData = vo
|
||||
super(user, container, delegate, compressibleRenderers, asObjectTreeOptions<T, TFilterData>(compressedTreeNodeProvider, options));
|
||||
}
|
||||
|
||||
setChildren(element: T | null, children?: ISequence<ICompressedTreeElement<T>>): void {
|
||||
setChildren(element: T | null, children: Iterable<ICompressedTreeElement<T>> = Iterable.empty()): void {
|
||||
this.model.setChildren(element, children);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { Iterator, ISequence, getSequenceIterator } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { IndexTreeModel, IIndexTreeModelOptions } from 'vs/base/browser/ui/tree/indexTreeModel';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ITreeModel, ITreeNode, ITreeElement, ITreeSorter, ICollapseStateChangeEvent, ITreeModelSpliceEvent, TreeError } from 'vs/base/browser/ui/tree/tree';
|
||||
@@ -14,7 +14,7 @@ import { mergeSort } from 'vs/base/common/arrays';
|
||||
export type ITreeNodeCallback<T, TFilterData> = (node: ITreeNode<T, TFilterData>) => void;
|
||||
|
||||
export interface IObjectTreeModel<T extends NonNullable<any>, TFilterData extends NonNullable<any> = void> extends ITreeModel<T | null, TFilterData, T | null> {
|
||||
setChildren(element: T | null, children: ISequence<ITreeElement<T>> | undefined): void;
|
||||
setChildren(element: T | null, children: Iterable<ITreeElement<T>> | undefined): void;
|
||||
resort(element?: T | null, recursive?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
|
||||
|
||||
setChildren(
|
||||
element: T | null,
|
||||
children: ISequence<ITreeElement<T>> | undefined,
|
||||
children: Iterable<ITreeElement<T>> = Iterable.empty(),
|
||||
onDidCreateNode?: ITreeNodeCallback<T, TFilterData>,
|
||||
onDidDeleteNode?: ITreeNodeCallback<T, TFilterData>
|
||||
): void {
|
||||
@@ -72,7 +72,7 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
|
||||
|
||||
private _setChildren(
|
||||
location: number[],
|
||||
children: ISequence<ITreeElement<T>> | undefined,
|
||||
children: Iterable<ITreeElement<T>> = Iterable.empty(),
|
||||
onDidCreateNode?: ITreeNodeCallback<T, TFilterData>,
|
||||
onDidDeleteNode?: ITreeNodeCallback<T, TFilterData>
|
||||
): void {
|
||||
@@ -132,14 +132,12 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
|
||||
);
|
||||
}
|
||||
|
||||
private preserveCollapseState(elements: ISequence<ITreeElement<T>> | undefined): ISequence<ITreeElement<T>> {
|
||||
let iterator = elements ? getSequenceIterator(elements) : Iterator.empty<ITreeElement<T>>();
|
||||
|
||||
private preserveCollapseState(elements: Iterable<ITreeElement<T>> = Iterable.empty()): Iterable<ITreeElement<T>> {
|
||||
if (this.sorter) {
|
||||
iterator = Iterator.fromArray(mergeSort(Iterator.collect(iterator), this.sorter.compare.bind(this.sorter)));
|
||||
elements = mergeSort([...elements], this.sorter.compare.bind(this.sorter));
|
||||
}
|
||||
|
||||
return Iterator.map(iterator, treeElement => {
|
||||
return Iterable.map(elements, treeElement => {
|
||||
let node = this.nodes.get(treeElement.element);
|
||||
|
||||
if (!node && this.identityProvider) {
|
||||
@@ -182,14 +180,14 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
|
||||
this._setChildren(location, this.resortChildren(node, recursive));
|
||||
}
|
||||
|
||||
private resortChildren(node: ITreeNode<T | null, TFilterData>, recursive: boolean, first = true): ISequence<ITreeElement<T>> {
|
||||
let childrenNodes = Iterator.fromArray(node.children as ITreeNode<T, TFilterData>[]);
|
||||
private resortChildren(node: ITreeNode<T | null, TFilterData>, recursive: boolean, first = true): Iterable<ITreeElement<T>> {
|
||||
let childrenNodes = [...node.children] as ITreeNode<T, TFilterData>[];
|
||||
|
||||
if (recursive || first) {
|
||||
childrenNodes = Iterator.fromArray(Iterator.collect(childrenNodes).sort(this.sorter!.compare.bind(this.sorter)));
|
||||
childrenNodes = mergeSort(childrenNodes, this.sorter!.compare.bind(this.sorter)) as ITreeNode<T, TFilterData>[];
|
||||
}
|
||||
|
||||
return Iterator.map<ITreeNode<T | null, TFilterData>, ITreeElement<T>>(childrenNodes, node => ({
|
||||
return Iterable.map<ITreeNode<T | null, TFilterData>, ITreeElement<T>>(childrenNodes, node => ({
|
||||
element: node.element as T,
|
||||
collapsible: node.collapsible,
|
||||
collapsed: node.collapsed,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { IListRenderer, IListDragOverReaction, IListDragAndDrop, ListDragOverEffect } from 'vs/base/browser/ui/list/list';
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
|
||||
@@ -74,7 +73,7 @@ export interface ITreeSorter<T> {
|
||||
|
||||
export interface ITreeElement<T> {
|
||||
readonly element: T;
|
||||
readonly children?: Iterator<ITreeElement<T>> | ITreeElement<T>[];
|
||||
readonly children?: Iterable<ITreeElement<T>>;
|
||||
readonly collapsible?: boolean;
|
||||
readonly collapsed?: boolean;
|
||||
}
|
||||
@@ -167,12 +166,12 @@ export interface ITreeNavigator<T> {
|
||||
|
||||
export interface IDataSource<TInput, T> {
|
||||
hasChildren?(element: TInput | T): boolean;
|
||||
getChildren(element: TInput | T): T[];
|
||||
getChildren(element: TInput | T): Iterable<T>;
|
||||
}
|
||||
|
||||
export interface IAsyncDataSource<TInput, T> {
|
||||
hasChildren(element: TInput | T): boolean;
|
||||
getChildren(element: TInput | T): T[] | Promise<T[]>;
|
||||
getChildren(element: TInput | T): Iterable<T> | Promise<Iterable<T>>;
|
||||
}
|
||||
|
||||
export const enum TreeDragOverBubble {
|
||||
|
||||
@@ -19,6 +19,10 @@ export function fromNow(date: number | Date, appendAgoLabel?: boolean): string {
|
||||
}
|
||||
|
||||
const seconds = Math.round((new Date().getTime() - date) / 1000);
|
||||
if (seconds < -30) {
|
||||
return localize('date.fromNow.in', 'in {0}', fromNow(new Date().getTime() + seconds * 1000, false));
|
||||
}
|
||||
|
||||
if (seconds < 30) {
|
||||
return localize('date.fromNow.now', 'now');
|
||||
}
|
||||
|
||||
@@ -559,6 +559,8 @@ export function fuzzyScore(pattern: string, patternLow: string, patternStart: nu
|
||||
let patternPos = patternStart;
|
||||
let wordPos = wordStart;
|
||||
|
||||
let hasStrongFirstMatch = false;
|
||||
|
||||
// There will be a match, fill in tables
|
||||
for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
|
||||
|
||||
@@ -566,6 +568,10 @@ export function fuzzyScore(pattern: string, patternLow: string, patternStart: nu
|
||||
|
||||
const score = _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos);
|
||||
|
||||
if (patternPos === patternStart && score > 1) {
|
||||
hasStrongFirstMatch = true;
|
||||
}
|
||||
|
||||
_scores[row][column] = score;
|
||||
|
||||
const diag = _table[row - 1][column - 1] + (score > 1 ? 1 : score);
|
||||
@@ -604,6 +610,10 @@ export function fuzzyScore(pattern: string, patternLow: string, patternStart: nu
|
||||
printTables(pattern, patternStart, word, wordStart);
|
||||
}
|
||||
|
||||
if (!hasStrongFirstMatch && !firstMatchCanBeWeak) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
_matchesCount = 0;
|
||||
_topScore = -100;
|
||||
_wordStart = wordStart;
|
||||
|
||||
@@ -526,15 +526,45 @@ function createMatches(offsets: number[] | undefined): IMatch[] {
|
||||
}
|
||||
|
||||
function normalizeMatches(matches: IMatch[]): IMatch[] {
|
||||
const positions = new Set<number>();
|
||||
|
||||
for (const match of matches) {
|
||||
for (let i = match.start; i < match.end; i++) {
|
||||
positions.add(i);
|
||||
// sort matches by start to be able to normalize
|
||||
const sortedMatches = matches.sort((matchA, matchB) => {
|
||||
return matchA.start - matchB.start;
|
||||
});
|
||||
|
||||
// merge matches that overlap
|
||||
const normalizedMatches: IMatch[] = [];
|
||||
let currentMatch: IMatch | undefined = undefined;
|
||||
for (const match of sortedMatches) {
|
||||
|
||||
// if we have no current match or the matches
|
||||
// do not overlap, we take it as is and remember
|
||||
// it for future merging
|
||||
if (!currentMatch || !matchOverlaps(currentMatch, match)) {
|
||||
currentMatch = match;
|
||||
normalizedMatches.push(match);
|
||||
}
|
||||
|
||||
// otherwise we merge the matches
|
||||
else {
|
||||
currentMatch.start = Math.min(currentMatch.start, match.start);
|
||||
currentMatch.end = Math.max(currentMatch.end, match.end);
|
||||
}
|
||||
}
|
||||
|
||||
return createMatches(Array.from(positions.values()).sort((a, b) => a - b));
|
||||
return normalizedMatches;
|
||||
}
|
||||
|
||||
function matchOverlaps(matchA: IMatch, matchB: IMatch): boolean {
|
||||
if (matchA.end < matchB.start) {
|
||||
return false; // A ends before B starts
|
||||
}
|
||||
|
||||
if (matchB.end < matchA.start) {
|
||||
return false; // B ends before A starts
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INavigator, ArrayNavigator } from 'vs/base/common/iterator';
|
||||
import { INavigator, ArrayNavigator } from 'vs/base/common/navigator';
|
||||
|
||||
export class HistoryNavigator<T> implements INavigator<T> {
|
||||
|
||||
@@ -45,10 +45,6 @@ export class HistoryNavigator<T> implements INavigator<T> {
|
||||
return this._navigator.current();
|
||||
}
|
||||
|
||||
public parent(): null {
|
||||
return null;
|
||||
}
|
||||
|
||||
public first(): T | null {
|
||||
return this._navigator.first();
|
||||
}
|
||||
|
||||
@@ -3,39 +3,17 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface IteratorDefinedResult<T> {
|
||||
readonly done: false;
|
||||
readonly value: T;
|
||||
}
|
||||
export interface IteratorUndefinedResult {
|
||||
readonly done: true;
|
||||
readonly value: undefined;
|
||||
}
|
||||
export const FIN: IteratorUndefinedResult = { done: true, value: undefined };
|
||||
export type IteratorResult<T> = IteratorDefinedResult<T> | IteratorUndefinedResult;
|
||||
|
||||
export interface Iterator<T> {
|
||||
next(): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface NativeIteratorYieldResult<TYield> {
|
||||
done?: false;
|
||||
value: TYield;
|
||||
}
|
||||
|
||||
interface NativeIteratorReturnResult<TReturn> {
|
||||
done: true;
|
||||
value: TReturn;
|
||||
}
|
||||
|
||||
type NativeIteratorResult<T, TReturn = any> = NativeIteratorYieldResult<T> | NativeIteratorReturnResult<TReturn>;
|
||||
|
||||
export interface NativeIterator<T> {
|
||||
next(): NativeIteratorResult<T>;
|
||||
}
|
||||
|
||||
export namespace Iterable {
|
||||
|
||||
const _empty: Iterable<any> = Object.freeze([]);
|
||||
export function empty<T>(): Iterable<T> {
|
||||
return _empty;
|
||||
}
|
||||
|
||||
export function from<T>(iterable: Iterable<T> | undefined | null): Iterable<T> {
|
||||
return iterable || _empty;
|
||||
}
|
||||
|
||||
export function first<T>(iterable: Iterable<T>): T | undefined {
|
||||
return iterable[Symbol.iterator]().next().value;
|
||||
}
|
||||
@@ -52,291 +30,48 @@ export namespace Iterable {
|
||||
export function* filter<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): Iterable<T> {
|
||||
for (const element of iterable) {
|
||||
if (predicate(element)) {
|
||||
return yield element;
|
||||
yield element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function* map<T, R>(iterable: Iterable<T>, fn: (t: T) => R): Iterable<R> {
|
||||
for (const element of iterable) {
|
||||
return yield fn(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export module Iterator {
|
||||
const _empty: Iterator<any> = {
|
||||
next() {
|
||||
return FIN;
|
||||
}
|
||||
};
|
||||
|
||||
export function empty<T>(): Iterator<T> {
|
||||
return _empty;
|
||||
}
|
||||
|
||||
export function single<T>(value: T): Iterator<T> {
|
||||
let done = false;
|
||||
|
||||
return {
|
||||
next(): IteratorResult<T> {
|
||||
if (done) {
|
||||
return FIN;
|
||||
}
|
||||
|
||||
done = true;
|
||||
return { done: false, value };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function fromArray<T>(array: ReadonlyArray<T>, index = 0, length = array.length): Iterator<T> {
|
||||
return {
|
||||
next(): IteratorResult<T> {
|
||||
if (index >= length) {
|
||||
return FIN;
|
||||
}
|
||||
|
||||
return { done: false, value: array[index++] };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function fromNativeIterator<T>(it: NativeIterator<T>): Iterator<T> {
|
||||
return {
|
||||
next(): IteratorResult<T> {
|
||||
const result = it.next();
|
||||
|
||||
if (result.done) {
|
||||
return FIN;
|
||||
}
|
||||
|
||||
return { done: false, value: result.value };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function from<T>(elements: Iterator<T> | T[] | undefined): Iterator<T> {
|
||||
if (!elements) {
|
||||
return Iterator.empty();
|
||||
} else if (Array.isArray(elements)) {
|
||||
return Iterator.fromArray(elements);
|
||||
} else {
|
||||
return elements;
|
||||
yield fn(element);
|
||||
}
|
||||
}
|
||||
|
||||
export function map<T, R>(iterator: Iterator<T>, fn: (t: T) => R): Iterator<R> {
|
||||
return {
|
||||
next() {
|
||||
const element = iterator.next();
|
||||
if (element.done) {
|
||||
return FIN;
|
||||
} else {
|
||||
return { done: false, value: fn(element.value) };
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function filter<T>(iterator: Iterator<T>, fn: (t: T) => boolean): Iterator<T> {
|
||||
return {
|
||||
next() {
|
||||
while (true) {
|
||||
const element = iterator.next();
|
||||
if (element.done) {
|
||||
return FIN;
|
||||
}
|
||||
if (fn(element.value)) {
|
||||
return { done: false, value: element.value };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function some<T>(iterator: Iterator<T> | NativeIterator<T>, fn: (t: T) => boolean): boolean {
|
||||
while (true) {
|
||||
const element = iterator.next();
|
||||
if (element.done) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fn(element.value)) {
|
||||
return true;
|
||||
export function* concat<T>(...iterables: Iterable<T>[]): Iterable<T> {
|
||||
for (const iterable of iterables) {
|
||||
for (const element of iterable) {
|
||||
yield element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function forEach<T>(iterator: Iterator<T>, fn: (t: T) => void): void {
|
||||
for (let next = iterator.next(); !next.done; next = iterator.next()) {
|
||||
fn(next.value);
|
||||
}
|
||||
}
|
||||
|
||||
export function collect<T>(iterator: Iterator<T>, atMost: number = Number.POSITIVE_INFINITY): T[] {
|
||||
const result: T[] = [];
|
||||
/**
|
||||
* Consumes `atMost` elements from iterable and returns the consumed elements,
|
||||
* and an iterable for the rest of the elements.
|
||||
*/
|
||||
export function consume<T>(iterable: Iterable<T>, atMost: number = Number.POSITIVE_INFINITY): [T[], Iterable<T>] {
|
||||
const consumed: T[] = [];
|
||||
|
||||
if (atMost === 0) {
|
||||
return result;
|
||||
return [consumed, iterable];
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
const iterator = iterable[Symbol.iterator]();
|
||||
|
||||
for (let next = iterator.next(); !next.done; next = iterator.next()) {
|
||||
result.push(next.value);
|
||||
for (let i = 0; i < atMost; i++) {
|
||||
const next = iterator.next();
|
||||
|
||||
if (++i >= atMost) {
|
||||
break;
|
||||
if (next.done) {
|
||||
return [consumed, Iterable.empty()];
|
||||
}
|
||||
|
||||
consumed.push(next.value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function concat<T>(...iterators: Iterator<T>[]): Iterator<T> {
|
||||
let i = 0;
|
||||
|
||||
return {
|
||||
next() {
|
||||
if (i >= iterators.length) {
|
||||
return FIN;
|
||||
}
|
||||
|
||||
const iterator = iterators[i];
|
||||
const result = iterator.next();
|
||||
|
||||
if (result.done) {
|
||||
i++;
|
||||
return this.next();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function chain<T>(iterator: Iterator<T>): ChainableIterator<T> {
|
||||
return new ChainableIterator(iterator);
|
||||
return [consumed, { [Symbol.iterator]() { return iterator; } }];
|
||||
}
|
||||
}
|
||||
|
||||
export class ChainableIterator<T> implements Iterator<T> {
|
||||
|
||||
constructor(private it: Iterator<T>) { }
|
||||
|
||||
next(): IteratorResult<T> { return this.it.next(); }
|
||||
map<R>(fn: (t: T) => R): ChainableIterator<R> { return new ChainableIterator(Iterator.map(this.it, fn)); }
|
||||
filter(fn: (t: T) => boolean): ChainableIterator<T> { return new ChainableIterator(Iterator.filter(this.it, fn)); }
|
||||
}
|
||||
|
||||
export type ISequence<T> = Iterator<T> | T[];
|
||||
|
||||
export function getSequenceIterator<T>(arg: ISequence<T> | undefined): Iterator<T> {
|
||||
if (Array.isArray(arg)) {
|
||||
return Iterator.fromArray(arg);
|
||||
} else if (!arg) {
|
||||
return Iterator.empty();
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
export interface INextIterator<T> {
|
||||
next(): T | null;
|
||||
}
|
||||
|
||||
export class ArrayIterator<T> implements INextIterator<T> {
|
||||
|
||||
private readonly items: readonly T[];
|
||||
protected start: number;
|
||||
protected end: number;
|
||||
protected index: number;
|
||||
|
||||
constructor(items: readonly T[], start: number = 0, end: number = items.length, index = start - 1) {
|
||||
this.items = items;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public first(): T | null {
|
||||
this.index = this.start;
|
||||
return this.current();
|
||||
}
|
||||
|
||||
public next(): T | null {
|
||||
this.index = Math.min(this.index + 1, this.end);
|
||||
return this.current();
|
||||
}
|
||||
|
||||
protected current(): T | null {
|
||||
if (this.index === this.start - 1 || this.index === this.end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.items[this.index];
|
||||
}
|
||||
}
|
||||
|
||||
export class ArrayNavigator<T> extends ArrayIterator<T> implements INavigator<T> {
|
||||
|
||||
constructor(items: readonly T[], start: number = 0, end: number = items.length, index = start - 1) {
|
||||
super(items, start, end, index);
|
||||
}
|
||||
|
||||
public current(): T | null {
|
||||
return super.current();
|
||||
}
|
||||
|
||||
public previous(): T | null {
|
||||
this.index = Math.max(this.index - 1, this.start - 1);
|
||||
return this.current();
|
||||
}
|
||||
|
||||
public first(): T | null {
|
||||
this.index = this.start;
|
||||
return this.current();
|
||||
}
|
||||
|
||||
public last(): T | null {
|
||||
this.index = this.end - 1;
|
||||
return this.current();
|
||||
}
|
||||
|
||||
public parent(): T | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export class MappedIterator<T, R> implements INextIterator<R> {
|
||||
|
||||
constructor(protected iterator: INextIterator<T>, protected fn: (item: T | null) => R) {
|
||||
// noop
|
||||
}
|
||||
|
||||
next() { return this.fn(this.iterator.next()); }
|
||||
}
|
||||
|
||||
export interface INavigator<T> extends INextIterator<T> {
|
||||
current(): T | null;
|
||||
previous(): T | null;
|
||||
parent(): T | null;
|
||||
first(): T | null;
|
||||
last(): T | null;
|
||||
next(): T | null;
|
||||
}
|
||||
|
||||
export class MappedNavigator<T, R> extends MappedIterator<T, R> implements INavigator<R> {
|
||||
|
||||
constructor(protected navigator: INavigator<T>, fn: (item: T | null) => R) {
|
||||
super(navigator, fn);
|
||||
}
|
||||
|
||||
current() { return this.fn(this.navigator.current()); }
|
||||
previous() { return this.fn(this.navigator.previous()); }
|
||||
parent() { return this.fn(this.navigator.parent()); }
|
||||
first() { return this.fn(this.navigator.first()); }
|
||||
last() { return this.fn(this.navigator.last()); }
|
||||
next() { return this.fn(this.navigator.next()); }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface IWorkspaceFolderProvider {
|
||||
}
|
||||
|
||||
export interface IUserHomeProvider {
|
||||
userHome: string;
|
||||
userHome?: URI;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +63,8 @@ export function getPathLabel(resource: URI | string, userHomeProvider?: IUserHom
|
||||
|
||||
// normalize and tildify (macOS, Linux only)
|
||||
let res = normalize(resource.fsPath);
|
||||
if (!isWindows && userHomeProvider) {
|
||||
res = tildify(res, userHomeProvider.userHome);
|
||||
if (!isWindows && userHomeProvider?.userHome) {
|
||||
res = tildify(res, userHomeProvider.userHome.fsPath);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { FIN } from './iterator';
|
||||
import { compareIgnoreCase, compare } from 'vs/base/common/strings';
|
||||
|
||||
/**
|
||||
* @deprecated ES6: use `[...SetOrMap.values()]`
|
||||
@@ -56,8 +56,8 @@ export function setToString<K>(set: Set<K>): string {
|
||||
return `Set(${set.size}) {${entries.join(', ')}}`;
|
||||
}
|
||||
|
||||
export interface IKeyIterator {
|
||||
reset(key: string): this;
|
||||
export interface IKeyIterator<K> {
|
||||
reset(key: K): this;
|
||||
next(): this;
|
||||
|
||||
hasNext(): boolean;
|
||||
@@ -65,7 +65,7 @@ export interface IKeyIterator {
|
||||
value(): string;
|
||||
}
|
||||
|
||||
export class StringIterator implements IKeyIterator {
|
||||
export class StringIterator implements IKeyIterator<string> {
|
||||
|
||||
private _value: string = '';
|
||||
private _pos: number = 0;
|
||||
@@ -96,7 +96,7 @@ export class StringIterator implements IKeyIterator {
|
||||
}
|
||||
}
|
||||
|
||||
export class PathIterator implements IKeyIterator {
|
||||
export class PathIterator implements IKeyIterator<string> {
|
||||
|
||||
private _value!: string;
|
||||
private _from!: number;
|
||||
@@ -163,33 +163,118 @@ export class PathIterator implements IKeyIterator {
|
||||
}
|
||||
}
|
||||
|
||||
class TernarySearchTreeNode<E> {
|
||||
const enum UriIteratorState {
|
||||
Scheme = 1, Authority = 2, Path = 3, Query = 4, Fragment = 5
|
||||
}
|
||||
|
||||
export class UriIterator implements IKeyIterator<URI> {
|
||||
|
||||
private _pathIterator = new PathIterator(false);
|
||||
private _value!: URI;
|
||||
private _states: UriIteratorState[] = [];
|
||||
private _stateIdx: number = 0;
|
||||
|
||||
reset(key: URI): this {
|
||||
this._value = key;
|
||||
this._states = [];
|
||||
if (this._value.scheme) {
|
||||
this._states.push(UriIteratorState.Scheme);
|
||||
}
|
||||
if (this._value.authority) {
|
||||
this._states.push(UriIteratorState.Authority);
|
||||
}
|
||||
if (this._value.path) {
|
||||
this._pathIterator.reset(key.path);
|
||||
if (this._pathIterator.value()) {
|
||||
this._states.push(UriIteratorState.Path);
|
||||
}
|
||||
}
|
||||
if (this._value.query) {
|
||||
this._states.push(UriIteratorState.Query);
|
||||
}
|
||||
if (this._value.fragment) {
|
||||
this._states.push(UriIteratorState.Fragment);
|
||||
}
|
||||
this._stateIdx = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
next(): this {
|
||||
if (this._states[this._stateIdx] === UriIteratorState.Path && this._pathIterator.hasNext()) {
|
||||
this._pathIterator.next();
|
||||
} else {
|
||||
this._stateIdx += 1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
hasNext(): boolean {
|
||||
return (this._states[this._stateIdx] === UriIteratorState.Path && this._pathIterator.hasNext())
|
||||
|| this._stateIdx < this._states.length - 1;
|
||||
}
|
||||
|
||||
cmp(a: string): number {
|
||||
if (this._states[this._stateIdx] === UriIteratorState.Scheme) {
|
||||
return compareIgnoreCase(a, this._value.scheme);
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Authority) {
|
||||
return compareIgnoreCase(a, this._value.authority);
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Path) {
|
||||
return this._pathIterator.cmp(a);
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Query) {
|
||||
return compare(a, this._value.query);
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Fragment) {
|
||||
return compare(a, this._value.fragment);
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
value(): string {
|
||||
if (this._states[this._stateIdx] === UriIteratorState.Scheme) {
|
||||
return this._value.scheme;
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Authority) {
|
||||
return this._value.authority;
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Path) {
|
||||
return this._pathIterator.value();
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Query) {
|
||||
return this._value.query;
|
||||
} else if (this._states[this._stateIdx] === UriIteratorState.Fragment) {
|
||||
return this._value.fragment;
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
class TernarySearchTreeNode<K, V> {
|
||||
segment!: string;
|
||||
value: E | undefined;
|
||||
key!: string;
|
||||
left: TernarySearchTreeNode<E> | undefined;
|
||||
mid: TernarySearchTreeNode<E> | undefined;
|
||||
right: TernarySearchTreeNode<E> | undefined;
|
||||
value: V | undefined;
|
||||
key!: K;
|
||||
left: TernarySearchTreeNode<K, V> | undefined;
|
||||
mid: TernarySearchTreeNode<K, V> | undefined;
|
||||
right: TernarySearchTreeNode<K, V> | undefined;
|
||||
|
||||
isEmpty(): boolean {
|
||||
return !this.left && !this.mid && !this.right && !this.value;
|
||||
}
|
||||
}
|
||||
|
||||
export class TernarySearchTree<E> {
|
||||
export class TernarySearchTree<K, V> {
|
||||
|
||||
static forPaths<E>(): TernarySearchTree<E> {
|
||||
return new TernarySearchTree<E>(new PathIterator());
|
||||
static forUris<E>(): TernarySearchTree<URI, E> {
|
||||
return new TernarySearchTree<URI, E>(new UriIterator());
|
||||
}
|
||||
|
||||
static forStrings<E>(): TernarySearchTree<E> {
|
||||
return new TernarySearchTree<E>(new StringIterator());
|
||||
static forPaths<E>(): TernarySearchTree<string, E> {
|
||||
return new TernarySearchTree<string, E>(new PathIterator());
|
||||
}
|
||||
|
||||
private _iter: IKeyIterator;
|
||||
private _root: TernarySearchTreeNode<E> | undefined;
|
||||
static forStrings<E>(): TernarySearchTree<string, E> {
|
||||
return new TernarySearchTree<string, E>(new StringIterator());
|
||||
}
|
||||
|
||||
constructor(segments: IKeyIterator) {
|
||||
private _iter: IKeyIterator<K>;
|
||||
private _root: TernarySearchTreeNode<K, V> | undefined;
|
||||
|
||||
constructor(segments: IKeyIterator<K>) {
|
||||
this._iter = segments;
|
||||
}
|
||||
|
||||
@@ -197,12 +282,12 @@ export class TernarySearchTree<E> {
|
||||
this._root = undefined;
|
||||
}
|
||||
|
||||
set(key: string, element: E): E | undefined {
|
||||
set(key: K, element: V): V | undefined {
|
||||
const iter = this._iter.reset(key);
|
||||
let node: TernarySearchTreeNode<E>;
|
||||
let node: TernarySearchTreeNode<K, V>;
|
||||
|
||||
if (!this._root) {
|
||||
this._root = new TernarySearchTreeNode<E>();
|
||||
this._root = new TernarySearchTreeNode<K, V>();
|
||||
this._root.segment = iter.value();
|
||||
}
|
||||
|
||||
@@ -212,7 +297,7 @@ export class TernarySearchTree<E> {
|
||||
if (val > 0) {
|
||||
// left
|
||||
if (!node.left) {
|
||||
node.left = new TernarySearchTreeNode<E>();
|
||||
node.left = new TernarySearchTreeNode<K, V>();
|
||||
node.left.segment = iter.value();
|
||||
}
|
||||
node = node.left;
|
||||
@@ -220,7 +305,7 @@ export class TernarySearchTree<E> {
|
||||
} else if (val < 0) {
|
||||
// right
|
||||
if (!node.right) {
|
||||
node.right = new TernarySearchTreeNode<E>();
|
||||
node.right = new TernarySearchTreeNode<K, V>();
|
||||
node.right.segment = iter.value();
|
||||
}
|
||||
node = node.right;
|
||||
@@ -229,7 +314,7 @@ export class TernarySearchTree<E> {
|
||||
// mid
|
||||
iter.next();
|
||||
if (!node.mid) {
|
||||
node.mid = new TernarySearchTreeNode<E>();
|
||||
node.mid = new TernarySearchTreeNode<K, V>();
|
||||
node.mid.segment = iter.value();
|
||||
}
|
||||
node = node.mid;
|
||||
@@ -243,7 +328,7 @@ export class TernarySearchTree<E> {
|
||||
return oldElement;
|
||||
}
|
||||
|
||||
get(key: string): E | undefined {
|
||||
get(key: K): V | undefined {
|
||||
const iter = this._iter.reset(key);
|
||||
let node = this._root;
|
||||
while (node) {
|
||||
@@ -265,10 +350,10 @@ export class TernarySearchTree<E> {
|
||||
return node ? node.value : undefined;
|
||||
}
|
||||
|
||||
delete(key: string): void {
|
||||
delete(key: K): void {
|
||||
|
||||
const iter = this._iter.reset(key);
|
||||
const stack: [-1 | 0 | 1, TernarySearchTreeNode<E>][] = [];
|
||||
const stack: [-1 | 0 | 1, TernarySearchTreeNode<K, V>][] = [];
|
||||
let node = this._root;
|
||||
|
||||
// find and unset node
|
||||
@@ -306,10 +391,10 @@ export class TernarySearchTree<E> {
|
||||
}
|
||||
}
|
||||
|
||||
findSubstr(key: string): E | undefined {
|
||||
findSubstr(key: K): V | undefined {
|
||||
const iter = this._iter.reset(key);
|
||||
let node = this._root;
|
||||
let candidate: E | undefined = undefined;
|
||||
let candidate: V | undefined = undefined;
|
||||
while (node) {
|
||||
const val = iter.cmp(node.segment);
|
||||
if (val > 0) {
|
||||
@@ -330,7 +415,7 @@ export class TernarySearchTree<E> {
|
||||
return node && node.value || candidate;
|
||||
}
|
||||
|
||||
findSuperstr(key: string): Iterator<E> | undefined {
|
||||
findSuperstr(key: K): Iterator<V> | undefined {
|
||||
const iter = this._iter.reset(key);
|
||||
let node = this._root;
|
||||
while (node) {
|
||||
@@ -357,11 +442,11 @@ export class TernarySearchTree<E> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _nodeIterator(node: TernarySearchTreeNode<E>): Iterator<E> {
|
||||
let res: { done: false; value: E; };
|
||||
private _nodeIterator(node: TernarySearchTreeNode<K, V>): Iterator<V> {
|
||||
let res: { done: false; value: V; };
|
||||
let idx: number;
|
||||
let data: E[];
|
||||
const next = (): IteratorResult<E> => {
|
||||
let data: V[];
|
||||
const next = (): IteratorResult<V> => {
|
||||
if (!data) {
|
||||
// lazy till first invocation
|
||||
data = [];
|
||||
@@ -369,7 +454,7 @@ export class TernarySearchTree<E> {
|
||||
this._forEach(node, value => data.push(value));
|
||||
}
|
||||
if (idx >= data.length) {
|
||||
return FIN;
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
@@ -382,11 +467,11 @@ export class TernarySearchTree<E> {
|
||||
return { next };
|
||||
}
|
||||
|
||||
forEach(callback: (value: E, index: string) => any) {
|
||||
forEach(callback: (value: V, index: K) => any) {
|
||||
this._forEach(this._root, callback);
|
||||
}
|
||||
|
||||
private _forEach(node: TernarySearchTreeNode<E> | undefined, callback: (value: E, index: string) => any) {
|
||||
private _forEach(node: TernarySearchTreeNode<K, V> | undefined, callback: (value: V, index: K) => any) {
|
||||
if (node) {
|
||||
// left
|
||||
this._forEach(node.left, callback);
|
||||
|
||||
50
src/vs/base/common/navigator.ts
Normal file
50
src/vs/base/common/navigator.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface INavigator<T> {
|
||||
current(): T | null;
|
||||
previous(): T | null;
|
||||
first(): T | null;
|
||||
last(): T | null;
|
||||
next(): T | null;
|
||||
}
|
||||
|
||||
export class ArrayNavigator<T> implements INavigator<T> {
|
||||
|
||||
constructor(
|
||||
private readonly items: readonly T[],
|
||||
protected start: number = 0,
|
||||
protected end: number = items.length,
|
||||
protected index = start - 1
|
||||
) { }
|
||||
|
||||
current(): T | null {
|
||||
if (this.index === this.start - 1 || this.index === this.end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.items[this.index];
|
||||
}
|
||||
|
||||
next(): T | null {
|
||||
this.index = Math.min(this.index + 1, this.end);
|
||||
return this.current();
|
||||
}
|
||||
|
||||
previous(): T | null {
|
||||
this.index = Math.max(this.index - 1, this.start - 1);
|
||||
return this.current();
|
||||
}
|
||||
|
||||
first(): T | null {
|
||||
this.index = this.start;
|
||||
return this.current();
|
||||
}
|
||||
|
||||
last(): T | null {
|
||||
this.index = this.end - 1;
|
||||
return this.current();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import * as paths from 'vs/base/common/path';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { relativePath, joinPath } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { PathIterator, values } from 'vs/base/common/map';
|
||||
@@ -15,7 +14,7 @@ export interface IResourceNode<T, C = void> {
|
||||
readonly relativePath: string;
|
||||
readonly name: string;
|
||||
readonly element: T | undefined;
|
||||
readonly children: Iterator<IResourceNode<T, C>>;
|
||||
readonly children: Iterable<IResourceNode<T, C>>;
|
||||
readonly childrenCount: number;
|
||||
readonly parent: IResourceNode<T, C> | undefined;
|
||||
readonly context: C;
|
||||
@@ -30,8 +29,8 @@ class Node<T, C> implements IResourceNode<T, C> {
|
||||
return this._children.size;
|
||||
}
|
||||
|
||||
get children(): Iterator<Node<T, C>> {
|
||||
return Iterator.fromArray(values(this._children));
|
||||
get children(): Iterable<Node<T, C>> {
|
||||
return [...values(this._children)];
|
||||
}
|
||||
|
||||
@memoize
|
||||
@@ -69,7 +68,9 @@ function collect<T, C>(node: IResourceNode<T, C>, result: T[]): T[] {
|
||||
result.push(node.element);
|
||||
}
|
||||
|
||||
Iterator.forEach(node.children, child => collect(child, result));
|
||||
for (const child of node.children) {
|
||||
collect(child, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import * as paths from 'vs/base/common/path';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { URI, uriToFsPath } from 'vs/base/common/uri';
|
||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
@@ -14,26 +14,7 @@ import { ParsedExpression, IExpression, parse } from 'vs/base/common/glob';
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
|
||||
export function originalFSPath(uri: URI): string {
|
||||
let value: string;
|
||||
const uriPath = uri.path;
|
||||
if (uri.authority && uriPath.length > 1 && uri.scheme === 'file') {
|
||||
// unc path: file://shares/c$/far/boo
|
||||
value = `//${uri.authority}${uriPath}`;
|
||||
} else if (
|
||||
isWindows
|
||||
&& uriPath.charCodeAt(0) === CharCode.Slash
|
||||
&& extpath.isWindowsDriveLetter(uriPath.charCodeAt(1))
|
||||
&& uriPath.charCodeAt(2) === CharCode.Colon
|
||||
) {
|
||||
value = uriPath.substr(1);
|
||||
} else {
|
||||
// other path
|
||||
value = uriPath;
|
||||
}
|
||||
if (isWindows) {
|
||||
value = value.replace(/\//g, '\\');
|
||||
}
|
||||
return value;
|
||||
return uriToFsPath(uri, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,7 +317,7 @@ export namespace DataUri {
|
||||
export class ResourceGlobMatcher {
|
||||
|
||||
private readonly globalExpression: ParsedExpression;
|
||||
private readonly expressionsByRoot: TernarySearchTree<{ root: URI, expression: ParsedExpression }> = TernarySearchTree.forPaths<{ root: URI, expression: ParsedExpression }>();
|
||||
private readonly expressionsByRoot: TernarySearchTree<string, { root: URI, expression: ParsedExpression }> = TernarySearchTree.forPaths<{ root: URI, expression: ParsedExpression }>();
|
||||
|
||||
constructor(
|
||||
globalExpression: IExpression,
|
||||
|
||||
@@ -295,11 +295,12 @@ export function compare(a: string, b: string): number {
|
||||
}
|
||||
}
|
||||
|
||||
export function compareIgnoreCase(a: string, b: string): number {
|
||||
const len = Math.min(a.length, b.length);
|
||||
for (let i = 0; i < len; i++) {
|
||||
let codeA = a.charCodeAt(i);
|
||||
let codeB = b.charCodeAt(i);
|
||||
export function compareIgnoreCase(a: string, b: string, aStart: number = 0, aEnd: number = a.length, bStart: number = 0, bEnd: number = b.length): number {
|
||||
|
||||
for (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {
|
||||
|
||||
let codeA = a.charCodeAt(aStart);
|
||||
let codeB = b.charCodeAt(bStart);
|
||||
|
||||
if (codeA === codeB) {
|
||||
// equal
|
||||
@@ -329,13 +330,16 @@ export function compareIgnoreCase(a: string, b: string): number {
|
||||
}
|
||||
}
|
||||
|
||||
if (a.length < b.length) {
|
||||
const aLen = aEnd - aStart;
|
||||
const bLen = bEnd - bStart;
|
||||
|
||||
if (aLen < bLen) {
|
||||
return -1;
|
||||
} else if (a.length > b.length) {
|
||||
} else if (aLen > bLen) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function isLowerAsciiLetter(code: number): boolean {
|
||||
|
||||
@@ -205,7 +205,7 @@ export class URI implements UriComponents {
|
||||
// if (this.scheme !== 'file') {
|
||||
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
|
||||
// }
|
||||
return _makeFsPath(this, false);
|
||||
return uriToFsPath(this, false);
|
||||
}
|
||||
|
||||
// ---- modify to new -------------------------
|
||||
@@ -349,7 +349,7 @@ export class URI implements UriComponents {
|
||||
}
|
||||
let newPath: string;
|
||||
if (isWindows && uri.scheme === 'file') {
|
||||
newPath = URI.file(paths.win32.join(_makeFsPath(uri, true), ...pathFragment)).path;
|
||||
newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path;
|
||||
} else {
|
||||
newPath = paths.posix.join(uri.path, ...pathFragment);
|
||||
}
|
||||
@@ -421,7 +421,7 @@ class _URI extends URI {
|
||||
|
||||
get fsPath(): string {
|
||||
if (!this._fsPath) {
|
||||
this._fsPath = _makeFsPath(this, false);
|
||||
this._fsPath = uriToFsPath(this, false);
|
||||
}
|
||||
return this._fsPath;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ function encodeURIComponentMinimal(path: string): string {
|
||||
/**
|
||||
* Compute `fsPath` for the given uri
|
||||
*/
|
||||
function _makeFsPath(uri: URI, keepDriveLetterCasing: boolean): string {
|
||||
export function uriToFsPath(uri: URI, keepDriveLetterCasing: boolean): string {
|
||||
|
||||
let value: string;
|
||||
if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
|
||||
|
||||
@@ -21,7 +21,7 @@ import { getMac } from 'vs/base/node/macAddress';
|
||||
// Sun xVM VirtualBox 08-00-27
|
||||
export const virtualMachineHint: { value(): number } = new class {
|
||||
|
||||
private _virtualMachineOUIs?: TernarySearchTree<boolean>;
|
||||
private _virtualMachineOUIs?: TernarySearchTree<string, boolean>;
|
||||
private _value?: number;
|
||||
|
||||
private _isVirtualMachineMacAdress(mac: string): boolean {
|
||||
|
||||
@@ -201,7 +201,8 @@
|
||||
flex: 1; /* make sure the icon label grows within the row */
|
||||
}
|
||||
|
||||
.quick-input-list .quick-input-list-rows > .quick-input-list-row .codicon {
|
||||
.quick-input-list .quick-input-list-rows > .quick-input-list-row .codicon[class*='codicon-'] {
|
||||
color: currentColor !important;
|
||||
vertical-align: sub;
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@
|
||||
.quick-input-list .quick-input-list-entry-action-bar .action-label {
|
||||
/*
|
||||
* By default, actions in the quick input action bar are hidden
|
||||
* until hovered over them or selected.
|
||||
* until hovered over them or selected.
|
||||
*/
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -825,7 +825,16 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
if (!this.visible) {
|
||||
return;
|
||||
}
|
||||
const hideInput = !!this._hideInput && this._items.length > 0; // do not allow to hide input without items
|
||||
let hideInput = false;
|
||||
let inputShownJustForScreenReader = false;
|
||||
if (!!this._hideInput && this._items.length > 0) {
|
||||
if (this.ui.isScreenReaderOptimized()) {
|
||||
// Always show input if screen reader attached https://github.com/microsoft/vscode/issues/94360
|
||||
inputShownJustForScreenReader = true;
|
||||
} else {
|
||||
hideInput = true;
|
||||
}
|
||||
}
|
||||
dom.toggleClass(this.ui.container, 'hidden-input', hideInput);
|
||||
const visibilities: Visibilities = {
|
||||
title: !!this.title || !!this.step,
|
||||
@@ -852,7 +861,9 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
if (this.ui.inputBox.placeholder !== (this.placeholder || '')) {
|
||||
this.ui.inputBox.placeholder = (this.placeholder || '');
|
||||
}
|
||||
if (this.ui.inputBox.ariaLabel !== this.ariaLabel) {
|
||||
if (inputShownJustForScreenReader) {
|
||||
this.ui.inputBox.ariaLabel = '';
|
||||
} else if (this.ui.inputBox.ariaLabel !== this.ariaLabel) {
|
||||
this.ui.inputBox.ariaLabel = this.ariaLabel;
|
||||
}
|
||||
this.ui.list.matchOnDescription = this.matchOnDescription;
|
||||
@@ -1072,6 +1083,8 @@ export class QuickInputController extends Disposable {
|
||||
private onHideEmitter = new Emitter<void>();
|
||||
readonly onHide = this.onHideEmitter.event;
|
||||
|
||||
private previousFocusElement?: HTMLElement;
|
||||
|
||||
constructor(private options: IQuickInputOptions) {
|
||||
super();
|
||||
this.idPrefix = options.idPrefix;
|
||||
@@ -1188,7 +1201,11 @@ export class QuickInputController extends Disposable {
|
||||
|
||||
const focusTracker = dom.trackFocus(container);
|
||||
this._register(focusTracker);
|
||||
this._register(dom.addDisposableListener(container, dom.EventType.FOCUS, e => {
|
||||
this.previousFocusElement = e.relatedTarget instanceof HTMLElement ? e.relatedTarget : undefined;
|
||||
}, true));
|
||||
this._register(focusTracker.onDidBlur(() => {
|
||||
this.previousFocusElement = undefined;
|
||||
if (!this.getUI().ignoreFocusOut && !this.options.ignoreFocusOut()) {
|
||||
this.hide(true);
|
||||
}
|
||||
@@ -1538,7 +1555,12 @@ export class QuickInputController extends Disposable {
|
||||
this.onHideEmitter.fire();
|
||||
this.getUI().container.style.display = 'none';
|
||||
if (!focusLost) {
|
||||
this.options.returnFocus();
|
||||
if (this.previousFocusElement && this.previousFocusElement.offsetParent) {
|
||||
this.previousFocusElement.focus();
|
||||
this.previousFocusElement = undefined;
|
||||
} else {
|
||||
this.options.returnFocus();
|
||||
}
|
||||
}
|
||||
controller.didHide();
|
||||
}
|
||||
|
||||
@@ -692,6 +692,10 @@ function compareEntries(elementA: ListElement, elementB: ListElement, lookFor: s
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (labelHighlightsA.length === 0 && labelHighlightsB.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return compareAnything(elementA.saneLabel, elementB.saneLabel, lookFor);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as Touch from 'vs/base/browser/touch';
|
||||
import * as Mouse from 'vs/base/browser/mouseEvent';
|
||||
import * as Keyboard from 'vs/base/browser/keyboardEvent';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import { INavigator } from 'sql/base/common/navigator';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as TreeDefaults from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
import * as Model from 'vs/base/parts/tree/browser/treeModel';
|
||||
import * as View from './treeView';
|
||||
import * as _ from 'vs/base/parts/tree/browser/tree';
|
||||
import { INavigator, MappedNavigator } from 'vs/base/common/iterator';
|
||||
import { INavigator, MappedNavigator } from 'sql/base/common/navigator';
|
||||
import { Event, Emitter, Relay } from 'vs/base/common/event';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as Assert from 'vs/base/common/assert';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IDisposable, combinedDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import { INavigator } from 'sql/base/common/navigator';
|
||||
import * as _ from './tree';
|
||||
import { Event, Emitter, EventMultiplexer, Relay } from 'vs/base/common/event';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as Mouse from 'vs/base/browser/mouseEvent';
|
||||
import * as Keyboard from 'vs/base/browser/keyboardEvent';
|
||||
import * as Model from 'vs/base/parts/tree/browser/treeModel';
|
||||
import * as dnd from './treeDnd';
|
||||
import { ArrayIterator, MappedIterator } from 'vs/base/common/iterator';
|
||||
import { ArrayNavigator } from 'vs/base/common/navigator';
|
||||
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { HeightMap, IViewItem } from 'vs/base/parts/tree/browser/treeViewModel';
|
||||
@@ -24,6 +24,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { DataTransfers, StaticDND, IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
import { DefaultTreestyler } from './treeDefaults';
|
||||
import { Delayer, timeout } from 'vs/base/common/async';
|
||||
import { MappedNavigator } from 'sql/base/common/navigator';
|
||||
|
||||
export interface IRow {
|
||||
element: HTMLElement | null;
|
||||
@@ -829,7 +830,7 @@ export class TreeView extends HeightMap {
|
||||
private onClearingInput(e: Model.IInputEvent): void {
|
||||
let item = <Model.Item>e.item;
|
||||
if (item) {
|
||||
this.onRemoveItems(new MappedIterator(item.getNavigator(), item => item && item.id));
|
||||
this.onRemoveItems(new MappedNavigator(item.getNavigator(), item => item && item.id));
|
||||
this.onRowsChanged();
|
||||
}
|
||||
}
|
||||
@@ -925,20 +926,20 @@ export class TreeView extends HeightMap {
|
||||
for (const diffChange of diff) {
|
||||
|
||||
if (diffChange.originalLength > 0) {
|
||||
this.onRemoveItems(new ArrayIterator(previousChildrenIds, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength));
|
||||
this.onRemoveItems(new ArrayNavigator(previousChildrenIds, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength));
|
||||
}
|
||||
|
||||
if (diffChange.modifiedLength > 0) {
|
||||
let beforeItem: Model.Item | null = afterModelItems[diffChange.modifiedStart - 1] || item;
|
||||
beforeItem = beforeItem.getDepth() > 0 ? beforeItem : null;
|
||||
|
||||
this.onInsertItems(new ArrayIterator(afterModelItems, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength), beforeItem ? beforeItem.id : null);
|
||||
this.onInsertItems(new ArrayNavigator(afterModelItems, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength), beforeItem ? beforeItem.id : null);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (skipDiff || diff.length) {
|
||||
this.onRemoveItems(new ArrayIterator(previousChildrenIds));
|
||||
this.onInsertItems(new ArrayIterator(afterModelItems), item.getDepth() > 0 ? item.id : null);
|
||||
this.onRemoveItems(new ArrayNavigator(previousChildrenIds));
|
||||
this.onInsertItems(new ArrayNavigator(afterModelItems), item.getDepth() > 0 ? item.id : null);
|
||||
}
|
||||
|
||||
if (skipDiff || diff.length) {
|
||||
@@ -985,7 +986,7 @@ export class TreeView extends HeightMap {
|
||||
let viewItem = this.items[item.id];
|
||||
if (viewItem) {
|
||||
viewItem.expanded = false;
|
||||
this.onRemoveItems(new MappedIterator(item.getNavigator(), item => item && item.id));
|
||||
this.onRemoveItems(new MappedNavigator(item.getNavigator(), item => item && item.id));
|
||||
this.onRowsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INextIterator, ArrayIterator } from 'vs/base/common/iterator';
|
||||
import { ArrayNavigator, INavigator } from 'vs/base/common/navigator';
|
||||
import { Item } from './treeModel';
|
||||
|
||||
export interface IViewItem {
|
||||
@@ -23,7 +23,7 @@ export class HeightMap {
|
||||
return !last ? 0 : last.top + last.height;
|
||||
}
|
||||
|
||||
onInsertItems(iterator: INextIterator<Item>, afterItemId: string | null = null): number | undefined {
|
||||
onInsertItems(iterator: INavigator<Item>, afterItemId: string | null = null): number | undefined {
|
||||
let item: Item | null = null;
|
||||
let viewItem: IViewItem;
|
||||
let i: number, j: number;
|
||||
@@ -81,7 +81,7 @@ export class HeightMap {
|
||||
}
|
||||
|
||||
// Contiguous items
|
||||
onRemoveItems(iterator: INextIterator<string>): void {
|
||||
onRemoveItems(iterator: INavigator<string>): void {
|
||||
let itemId: string | null = null;
|
||||
let viewItem: IViewItem;
|
||||
let startIndex: number | null = null;
|
||||
@@ -126,11 +126,11 @@ export class HeightMap {
|
||||
|
||||
onRefreshItemSet(items: Item[]): void {
|
||||
let sortedItems = items.sort((a, b) => this.indexes[a.id] - this.indexes[b.id]);
|
||||
this.onRefreshItems(new ArrayIterator(sortedItems));
|
||||
this.onRefreshItems(new ArrayNavigator(sortedItems));
|
||||
}
|
||||
|
||||
// Ordered, but not necessarily contiguous items
|
||||
onRefreshItems(iterator: INextIterator<Item>): void {
|
||||
onRefreshItems(iterator: INavigator<Item>): void {
|
||||
let item: Item | null = null;
|
||||
let viewItem: IViewItem;
|
||||
let newHeight: number;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ArrayIterator } from 'vs/base/common/iterator';
|
||||
import { ArrayNavigator } from 'vs/base/common/navigator';
|
||||
import { HeightMap, IViewItem } from 'vs/base/parts/tree/browser/treeViewModel';
|
||||
|
||||
function makeItem(id: any, height: any): any {
|
||||
@@ -139,7 +139,7 @@ suite('TreeView - HeightMap', () => {
|
||||
});
|
||||
|
||||
test('onRemoveItems at beginning', () => {
|
||||
rangeMap.onRemoveItems(new ArrayIterator(['a', 'b']));
|
||||
rangeMap.onRemoveItems(new ArrayNavigator(['a', 'b']));
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'c');
|
||||
assert.equal(rangeMap.itemAt(24), 'c');
|
||||
@@ -149,7 +149,7 @@ suite('TreeView - HeightMap', () => {
|
||||
});
|
||||
|
||||
test('onRemoveItems in middle', () => {
|
||||
rangeMap.onRemoveItems(new ArrayIterator(['c']));
|
||||
rangeMap.onRemoveItems(new ArrayNavigator(['c']));
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
assert.equal(rangeMap.itemAt(2), 'a');
|
||||
@@ -161,7 +161,7 @@ suite('TreeView - HeightMap', () => {
|
||||
});
|
||||
|
||||
test('onRemoveItems at end', () => {
|
||||
rangeMap.onRemoveItems(new ArrayIterator(['c', 'd']));
|
||||
rangeMap.onRemoveItems(new ArrayNavigator(['c', 'd']));
|
||||
|
||||
assert.equal(rangeMap.itemAt(0), 'a');
|
||||
assert.equal(rangeMap.itemAt(2), 'a');
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { compress, ICompressedTreeElement, ICompressedTreeNode, decompress, CompressedObjectTreeModel } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { ITreeNode } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
|
||||
@@ -16,7 +16,7 @@ interface IResolvedCompressedTreeElement<T> extends ICompressedTreeElement<T> {
|
||||
|
||||
function resolve<T>(treeElement: ICompressedTreeElement<T>): IResolvedCompressedTreeElement<T> {
|
||||
const result: any = { element: treeElement.element };
|
||||
const children = Iterator.collect(Iterator.map(Iterator.from(treeElement.children), resolve));
|
||||
const children = [...Iterable.map(Iterable.from(treeElement.children), resolve)];
|
||||
|
||||
if (treeElement.incompressible) {
|
||||
result.incompressible = true;
|
||||
@@ -315,25 +315,25 @@ suite('CompressedObjectTree', function () {
|
||||
const list: ITreeNode<ICompressedTreeNode<number>>[] = [];
|
||||
const model = new CompressedObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{ element: 0 },
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[0], [1], [2]]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{ element: 3 },
|
||||
{ element: 4 },
|
||||
{ element: 5 },
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[3], [4], [5]]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.empty());
|
||||
model.setChildren(null);
|
||||
assert.deepEqual(toArray(list), []);
|
||||
assert.equal(model.size, 0);
|
||||
});
|
||||
@@ -342,34 +342,34 @@ suite('CompressedObjectTree', function () {
|
||||
const list: ITreeNode<ICompressedTreeNode<number>>[] = [];
|
||||
const model = new CompressedObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[0], [10], [11], [12], [1], [2]]);
|
||||
assert.equal(model.size, 6);
|
||||
|
||||
model.setChildren(12, Iterator.fromArray([
|
||||
model.setChildren(12, [
|
||||
{ element: 120 },
|
||||
{ element: 121 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[0], [10], [11], [12], [120], [121], [1], [2]]);
|
||||
assert.equal(model.size, 8);
|
||||
|
||||
model.setChildren(0, Iterator.empty());
|
||||
model.setChildren(0);
|
||||
assert.deepEqual(toArray(list), [[0], [1], [2]]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.empty());
|
||||
model.setChildren(null);
|
||||
assert.deepEqual(toArray(list), []);
|
||||
assert.equal(model.size, 0);
|
||||
});
|
||||
@@ -378,50 +378,50 @@ suite('CompressedObjectTree', function () {
|
||||
const list: ITreeNode<ICompressedTreeNode<number>>[] = [];
|
||||
const model = new CompressedObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{
|
||||
element: 1, children: Iterator.fromArray([{
|
||||
element: 11, children: Iterator.fromArray([{
|
||||
element: 111, children: Iterator.fromArray([
|
||||
element: 1, children: [{
|
||||
element: 11, children: [{
|
||||
element: 111, children: [
|
||||
{ element: 1111 },
|
||||
{ element: 1112 },
|
||||
{ element: 1113 },
|
||||
])
|
||||
}])
|
||||
}])
|
||||
]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[1, 11, 111], [1111], [1112], [1113]]);
|
||||
assert.equal(model.size, 6);
|
||||
|
||||
model.setChildren(11, Iterator.fromArray([
|
||||
model.setChildren(11, [
|
||||
{ element: 111 },
|
||||
{ element: 112 },
|
||||
{ element: 113 },
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[1, 11], [111], [112], [113]]);
|
||||
assert.equal(model.size, 5);
|
||||
|
||||
model.setChildren(113, Iterator.fromArray([
|
||||
model.setChildren(113, [
|
||||
{ element: 1131 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[1, 11], [111], [112], [113, 1131]]);
|
||||
assert.equal(model.size, 6);
|
||||
|
||||
model.setChildren(1131, Iterator.fromArray([
|
||||
model.setChildren(1131, [
|
||||
{ element: 1132 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[1, 11], [111], [112], [113, 1131, 1132]]);
|
||||
assert.equal(model.size, 7);
|
||||
|
||||
model.setChildren(1131, Iterator.fromArray([
|
||||
model.setChildren(1131, [
|
||||
{ element: 1132 },
|
||||
{ element: 1133 },
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [[1, 11], [111], [112], [113, 1131], [1132], [1133]]);
|
||||
assert.equal(model.size, 8);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import * as assert from 'assert';
|
||||
import { ITreeNode, ITreeFilter, TreeVisibility } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { IndexTreeModel, IIndexTreeNode } from 'vs/base/browser/ui/tree/indexTreeModel';
|
||||
|
||||
function toSpliceable<T>(arr: T[]): ISpliceable<T> {
|
||||
@@ -34,11 +33,11 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{ element: 0 },
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 3);
|
||||
assert.deepEqual(list[0].element, 0);
|
||||
@@ -56,17 +55,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 6);
|
||||
assert.deepEqual(list[0].element, 0);
|
||||
@@ -93,17 +92,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, collapsed: true, children: Iterator.fromArray([
|
||||
element: 0, collapsed: true, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 3);
|
||||
assert.deepEqual(list[0].element, 0);
|
||||
@@ -121,11 +120,11 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{ element: 0 },
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 3);
|
||||
|
||||
@@ -146,17 +145,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 6);
|
||||
|
||||
@@ -180,17 +179,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 6);
|
||||
|
||||
@@ -208,17 +207,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, collapsed: true, children: Iterator.fromArray([
|
||||
element: 0, collapsed: true, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 3);
|
||||
|
||||
@@ -233,17 +232,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 6);
|
||||
|
||||
@@ -264,17 +263,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, collapsed: true, children: Iterator.fromArray([
|
||||
element: 0, collapsed: true, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 3);
|
||||
|
||||
@@ -304,7 +303,7 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 1, children: [
|
||||
{
|
||||
@@ -319,7 +318,7 @@ suite('IndexTreeModel', function () {
|
||||
{ element: 21 }
|
||||
]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 5);
|
||||
assert.deepEqual(toArray(list), [1, 11, 111, 2, 21]);
|
||||
@@ -337,13 +336,13 @@ suite('IndexTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 }
|
||||
])
|
||||
]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 2);
|
||||
|
||||
@@ -406,7 +405,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1, { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: [
|
||||
{ element: 1 },
|
||||
@@ -418,7 +417,7 @@ suite('IndexTreeModel', function () {
|
||||
{ element: 7 }
|
||||
]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 4);
|
||||
assert.deepEqual(toArray(list), [0, 2, 4, 6]);
|
||||
@@ -440,14 +439,14 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1, { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: [
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), []);
|
||||
});
|
||||
@@ -463,7 +462,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1, { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: [
|
||||
{ element: 1 },
|
||||
@@ -475,7 +474,7 @@ suite('IndexTreeModel', function () {
|
||||
{ element: 7 }
|
||||
]
|
||||
},
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0, 1, 2, 3, 4, 5, 6, 7]);
|
||||
|
||||
@@ -502,7 +501,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<string>('test', toSpliceable(list), 'root', { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 'vscode', children: [
|
||||
{ element: '.build' },
|
||||
@@ -522,7 +521,7 @@ suite('IndexTreeModel', function () {
|
||||
}
|
||||
]
|
||||
},
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 10);
|
||||
|
||||
@@ -548,7 +547,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<string>('test', toSpliceable(list), 'root', { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 'vscode', children: [
|
||||
{ element: '.build' },
|
||||
@@ -568,7 +567,7 @@ suite('IndexTreeModel', function () {
|
||||
}
|
||||
]
|
||||
},
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(list.length, 10);
|
||||
|
||||
@@ -594,7 +593,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<string>('test', toSpliceable(list), 'root', { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 'vscode', collapsed: true, children: [
|
||||
{ element: '.build' },
|
||||
@@ -614,7 +613,7 @@ suite('IndexTreeModel', function () {
|
||||
}
|
||||
]
|
||||
},
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), ['vscode']);
|
||||
|
||||
@@ -642,17 +641,17 @@ suite('IndexTreeModel', function () {
|
||||
const list: IIndexTreeNode<number>[] = [];
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1);
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(model.getNodeLocation(list[0]), [0]);
|
||||
assert.deepEqual(model.getNodeLocation(list[1]), [0, 0]);
|
||||
@@ -672,7 +671,7 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<number>('test', toSpliceable(list), -1, { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{
|
||||
element: 0, children: [
|
||||
{ element: 1 },
|
||||
@@ -684,7 +683,7 @@ suite('IndexTreeModel', function () {
|
||||
{ element: 7 }
|
||||
]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(model.getNodeLocation(list[0]), [0]);
|
||||
assert.deepEqual(model.getNodeLocation(list[1]), [0, 1]);
|
||||
@@ -704,11 +703,11 @@ suite('IndexTreeModel', function () {
|
||||
|
||||
const model = new IndexTreeModel<string>('test', toSpliceable(list), 'root', { filter });
|
||||
|
||||
model.splice([0], 0, Iterator.fromArray([
|
||||
model.splice([0], 0, [
|
||||
{ element: 'silver' },
|
||||
{ element: 'gold' },
|
||||
{ element: 'platinum' }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), ['silver', 'gold', 'platinum']);
|
||||
|
||||
@@ -716,11 +715,11 @@ suite('IndexTreeModel', function () {
|
||||
model.refilter();
|
||||
assert.deepEqual(toArray(list), ['platinum']);
|
||||
|
||||
model.splice([0], Number.POSITIVE_INFINITY, Iterator.fromArray([
|
||||
model.splice([0], Number.POSITIVE_INFINITY, [
|
||||
{ element: 'silver' },
|
||||
{ element: 'gold' },
|
||||
{ element: 'platinum' }
|
||||
]));
|
||||
]);
|
||||
assert.deepEqual(toArray(list), ['platinum']);
|
||||
|
||||
model.refilter();
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as assert from 'assert';
|
||||
import { ITreeNode, ITreeRenderer } from 'vs/base/browser/ui/tree/tree';
|
||||
import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list/list';
|
||||
import { ObjectTree, CompressibleObjectTree, ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
|
||||
|
||||
suite('ObjectTree', function () {
|
||||
@@ -46,17 +45,17 @@ suite('ObjectTree', function () {
|
||||
});
|
||||
|
||||
test('should be able to navigate', () => {
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
const navigator = tree.navigate();
|
||||
|
||||
@@ -87,17 +86,17 @@ suite('ObjectTree', function () {
|
||||
});
|
||||
|
||||
test('should skip collapsed nodes', () => {
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 0, collapsed: true, children: Iterator.fromArray([
|
||||
element: 0, collapsed: true, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
const navigator = tree.navigate();
|
||||
|
||||
@@ -118,17 +117,17 @@ suite('ObjectTree', function () {
|
||||
test('should skip filtered elements', () => {
|
||||
filter = el => el % 2 === 0;
|
||||
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
const navigator = tree.navigate();
|
||||
|
||||
@@ -150,17 +149,17 @@ suite('ObjectTree', function () {
|
||||
});
|
||||
|
||||
test('should be able to start from node', () => {
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
const navigator = tree.navigate(1);
|
||||
|
||||
@@ -291,50 +290,50 @@ suite('CompressibleObjectTree', function () {
|
||||
const tree = new CompressibleObjectTree<number>('test', container, new Delegate(), [new Renderer()]);
|
||||
tree.layout(200);
|
||||
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 1, children: Iterator.fromArray([{
|
||||
element: 11, children: Iterator.fromArray([{
|
||||
element: 111, children: Iterator.fromArray([
|
||||
element: 1, children: [{
|
||||
element: 11, children: [{
|
||||
element: 111, children: [
|
||||
{ element: 1111 },
|
||||
{ element: 1112 },
|
||||
{ element: 1113 },
|
||||
])
|
||||
}])
|
||||
}])
|
||||
]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
let rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11/111', '1111', '1112', '1113']);
|
||||
|
||||
tree.setChildren(11, Iterator.fromArray([
|
||||
tree.setChildren(11, [
|
||||
{ element: 111 },
|
||||
{ element: 112 },
|
||||
{ element: 113 },
|
||||
]));
|
||||
]);
|
||||
|
||||
rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11', '111', '112', '113']);
|
||||
|
||||
tree.setChildren(113, Iterator.fromArray([
|
||||
tree.setChildren(113, [
|
||||
{ element: 1131 }
|
||||
]));
|
||||
]);
|
||||
|
||||
rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11', '111', '112', '113/1131']);
|
||||
|
||||
tree.setChildren(1131, Iterator.fromArray([
|
||||
tree.setChildren(1131, [
|
||||
{ element: 1132 }
|
||||
]));
|
||||
]);
|
||||
|
||||
rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11', '111', '112', '113/1131/1132']);
|
||||
|
||||
tree.setChildren(1131, Iterator.fromArray([
|
||||
tree.setChildren(1131, [
|
||||
{ element: 1132 },
|
||||
{ element: 1133 },
|
||||
]));
|
||||
]);
|
||||
|
||||
rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11', '111', '112', '113/1131', '1132', '1133']);
|
||||
@@ -348,19 +347,19 @@ suite('CompressibleObjectTree', function () {
|
||||
const tree = new CompressibleObjectTree<number>('test', container, new Delegate(), [new Renderer()]);
|
||||
tree.layout(200);
|
||||
|
||||
tree.setChildren(null, Iterator.fromArray([
|
||||
tree.setChildren(null, [
|
||||
{
|
||||
element: 1, children: Iterator.fromArray([{
|
||||
element: 11, children: Iterator.fromArray([{
|
||||
element: 111, children: Iterator.fromArray([
|
||||
element: 1, children: [{
|
||||
element: 11, children: [{
|
||||
element: 111, children: [
|
||||
{ element: 1111 },
|
||||
{ element: 1112 },
|
||||
{ element: 1113 },
|
||||
])
|
||||
}])
|
||||
}])
|
||||
]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]));
|
||||
]);
|
||||
|
||||
let rows = toArray(container.querySelectorAll('.monaco-tl-contents')).map(row => row.textContent);
|
||||
assert.deepEqual(rows, ['1/11/111', '1111', '1112', '1113']);
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as assert from 'assert';
|
||||
import { ITreeNode } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ISpliceable } from 'vs/base/common/sequence';
|
||||
import { ObjectTreeModel } from 'vs/base/browser/ui/tree/objectTreeModel';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
|
||||
function toSpliceable<T>(arr: T[]): ISpliceable<T> {
|
||||
return {
|
||||
@@ -35,25 +34,25 @@ suite('ObjectTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new ObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{ element: 0 },
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0, 1, 2]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{ element: 3 },
|
||||
{ element: 4 },
|
||||
{ element: 5 },
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [3, 4, 5]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.empty());
|
||||
model.setChildren(null);
|
||||
assert.deepEqual(toArray(list), []);
|
||||
assert.equal(model.size, 0);
|
||||
});
|
||||
@@ -62,34 +61,34 @@ suite('ObjectTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new ObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{
|
||||
element: 0, children: Iterator.fromArray([
|
||||
element: 0, children: [
|
||||
{ element: 10 },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
])
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0, 10, 11, 12, 1, 2]);
|
||||
assert.equal(model.size, 6);
|
||||
|
||||
model.setChildren(12, Iterator.fromArray([
|
||||
model.setChildren(12, [
|
||||
{ element: 120 },
|
||||
{ element: 121 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0, 10, 11, 12, 120, 121, 1, 2]);
|
||||
assert.equal(model.size, 8);
|
||||
|
||||
model.setChildren(0, Iterator.empty());
|
||||
model.setChildren(0);
|
||||
assert.deepEqual(toArray(list), [0, 1, 2]);
|
||||
assert.equal(model.size, 3);
|
||||
|
||||
model.setChildren(null, Iterator.empty());
|
||||
model.setChildren(null);
|
||||
assert.deepEqual(toArray(list), []);
|
||||
assert.equal(model.size, 0);
|
||||
});
|
||||
@@ -98,16 +97,16 @@ suite('ObjectTreeModel', function () {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new ObjectTreeModel<number>('test', toSpliceable(list));
|
||||
|
||||
model.setChildren(null, Iterator.fromArray([
|
||||
model.setChildren(null, [
|
||||
{ element: 0, collapsed: true }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0]);
|
||||
|
||||
model.setChildren(0, Iterator.fromArray([
|
||||
model.setChildren(0, [
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]));
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0]);
|
||||
|
||||
|
||||
@@ -343,6 +343,36 @@ suite('Filters', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('Freeze when fjfj -> jfjf, https://github.com/microsoft/vscode/issues/91807', function () {
|
||||
assertMatches(
|
||||
'jfjfj',
|
||||
'fjfjfjfjfjfjfjfjfjfjfj',
|
||||
undefined, fuzzyScore
|
||||
);
|
||||
assertMatches(
|
||||
'jfjfjfjfjfjfjfjfjfj',
|
||||
'fjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj',
|
||||
undefined, fuzzyScore
|
||||
);
|
||||
assertMatches(
|
||||
'jfjfjfjfjfjfjfjfjfjjfjfjfjfjfjfjfjfjfjjfjfjfjfjfjfjfjfjfjjfjfjfjfjfjfjfjfjfjjfjfjfjfjfjfjfjfjfjjfjfjfjfjfjfjfjfjfj',
|
||||
'fjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj',
|
||||
undefined, fuzzyScore
|
||||
);
|
||||
assertMatches(
|
||||
'jfjfjfjfjfjfjfjfjfj',
|
||||
'fJfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj',
|
||||
'f^J^f^j^f^j^f^j^f^j^f^j^f^j^f^j^f^j^f^jfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj', // strong match
|
||||
fuzzyScore
|
||||
);
|
||||
assertMatches(
|
||||
'jfjfjfjfjfjfjfjfjfj',
|
||||
'fjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj',
|
||||
'f^j^f^j^f^j^f^j^f^j^f^j^f^j^f^j^f^j^f^jfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfjfj', // any match
|
||||
fuzzyScore, { firstMatchCanBeWeak: true }
|
||||
);
|
||||
});
|
||||
|
||||
test('fuzzyScore, issue #26423', function () {
|
||||
|
||||
assertMatches('baba', 'abababab', undefined, fuzzyScore);
|
||||
|
||||
@@ -4,19 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Iterator, Iterable } from 'vs/base/common/iterator';
|
||||
|
||||
suite('Iterator', () => {
|
||||
test('concat', () => {
|
||||
const first = Iterator.fromArray([1, 2, 3]);
|
||||
const second = Iterator.fromArray([4, 5, 6]);
|
||||
const third = Iterator.fromArray([7, 8, 9]);
|
||||
const actualIterator = Iterator.concat(first, second, third);
|
||||
const actual = Iterator.collect(actualIterator);
|
||||
|
||||
assert.deepEqual(actual, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
});
|
||||
});
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
|
||||
suite('Iterable', function () {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ResourceMap, TernarySearchTree, PathIterator, StringIterator, LinkedMap, Touch, LRUCache } from 'vs/base/common/map';
|
||||
import { ResourceMap, TernarySearchTree, PathIterator, StringIterator, LinkedMap, Touch, LRUCache, UriIterator } from 'vs/base/common/map';
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -312,7 +312,64 @@ suite('Map', () => {
|
||||
assert.equal(iter.hasNext(), false);
|
||||
});
|
||||
|
||||
function assertTernarySearchTree<E>(trie: TernarySearchTree<E>, ...elements: [string, E][]) {
|
||||
test('URIIterator', function () {
|
||||
const iter = new UriIterator();
|
||||
iter.reset(URI.parse('file:///usr/bin/file.txt'));
|
||||
|
||||
assert.equal(iter.value(), 'file');
|
||||
assert.equal(iter.cmp('FILE'), 0);
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
assert.equal(iter.value(), 'usr');
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
assert.equal(iter.value(), 'bin');
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
assert.equal(iter.value(), 'file.txt');
|
||||
assert.equal(iter.hasNext(), false);
|
||||
|
||||
|
||||
iter.reset(URI.parse('file://share/usr/bin/file.txt?foo'));
|
||||
|
||||
// scheme
|
||||
assert.equal(iter.value(), 'file');
|
||||
assert.equal(iter.cmp('FILE'), 0);
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
// authority
|
||||
assert.equal(iter.value(), 'share');
|
||||
assert.equal(iter.cmp('SHARe'), 0);
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
// path
|
||||
assert.equal(iter.value(), 'usr');
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
// path
|
||||
assert.equal(iter.value(), 'bin');
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
// path
|
||||
assert.equal(iter.value(), 'file.txt');
|
||||
assert.equal(iter.hasNext(), true);
|
||||
iter.next();
|
||||
|
||||
// query
|
||||
assert.equal(iter.value(), 'foo');
|
||||
assert.equal(iter.cmp('z') > 0, true);
|
||||
assert.equal(iter.cmp('a') < 0, true);
|
||||
assert.equal(iter.hasNext(), false);
|
||||
});
|
||||
|
||||
function assertTernarySearchTree<E>(trie: TernarySearchTree<string, E>, ...elements: [string, E][]) {
|
||||
const map = new Map<string, E>();
|
||||
for (const [key, value] of elements) {
|
||||
map.set(key, value);
|
||||
@@ -378,7 +435,7 @@ suite('Map', () => {
|
||||
});
|
||||
|
||||
test('TernarySearchTree - basics', function () {
|
||||
let trie = new TernarySearchTree<number>(new StringIterator());
|
||||
let trie = new TernarySearchTree<string, number>(new StringIterator());
|
||||
|
||||
trie.set('foo', 1);
|
||||
trie.set('bar', 2);
|
||||
@@ -408,7 +465,7 @@ suite('Map', () => {
|
||||
});
|
||||
|
||||
test('TernarySearchTree - delete & cleanup', function () {
|
||||
let trie = new TernarySearchTree<number>(new StringIterator());
|
||||
let trie = new TernarySearchTree<string, number>(new StringIterator());
|
||||
trie.set('foo', 1);
|
||||
trie.set('foobar', 2);
|
||||
trie.set('bar', 3);
|
||||
@@ -418,7 +475,7 @@ suite('Map', () => {
|
||||
});
|
||||
|
||||
test('TernarySearchTree (PathSegments) - basics', function () {
|
||||
let trie = new TernarySearchTree<number>(new PathIterator());
|
||||
let trie = new TernarySearchTree<string, number>(new PathIterator());
|
||||
|
||||
trie.set('/user/foo/bar', 1);
|
||||
trie.set('/user/foo', 2);
|
||||
@@ -442,7 +499,7 @@ suite('Map', () => {
|
||||
|
||||
test('TernarySearchTree (PathSegments) - lookup', function () {
|
||||
|
||||
const map = new TernarySearchTree<number>(new PathIterator());
|
||||
const map = new TernarySearchTree<string, number>(new PathIterator());
|
||||
map.set('/user/foo/bar', 1);
|
||||
map.set('/user/foo', 2);
|
||||
map.set('/user/foo/flip/flop', 3);
|
||||
@@ -456,7 +513,7 @@ suite('Map', () => {
|
||||
|
||||
test('TernarySearchTree (PathSegments) - superstr', function () {
|
||||
|
||||
const map = new TernarySearchTree<number>(new PathIterator());
|
||||
const map = new TernarySearchTree<string, number>(new PathIterator());
|
||||
map.set('/user/foo/bar', 1);
|
||||
map.set('/user/foo', 2);
|
||||
map.set('/user/foo/flip/flop', 3);
|
||||
@@ -493,6 +550,100 @@ suite('Map', () => {
|
||||
assert.equal(map.findSuperstr('/userr'), undefined);
|
||||
});
|
||||
|
||||
|
||||
test('TernarySearchTree (URI) - basics', function () {
|
||||
let trie = new TernarySearchTree<URI, number>(new UriIterator());
|
||||
|
||||
trie.set(URI.file('/user/foo/bar'), 1);
|
||||
trie.set(URI.file('/user/foo'), 2);
|
||||
trie.set(URI.file('/user/foo/flip/flop'), 3);
|
||||
|
||||
assert.equal(trie.get(URI.file('/user/foo/bar')), 1);
|
||||
assert.equal(trie.get(URI.file('/user/foo')), 2);
|
||||
assert.equal(trie.get(URI.file('/user/foo/flip/flop')), 3);
|
||||
|
||||
assert.equal(trie.findSubstr(URI.file('/user/bar')), undefined);
|
||||
assert.equal(trie.findSubstr(URI.file('/user/foo')), 2);
|
||||
assert.equal(trie.findSubstr(URI.file('/user/foo/ba')), 2);
|
||||
assert.equal(trie.findSubstr(URI.file('/user/foo/far/boo')), 2);
|
||||
assert.equal(trie.findSubstr(URI.file('/user/foo/bar')), 1);
|
||||
assert.equal(trie.findSubstr(URI.file('/user/foo/bar/far/boo')), 1);
|
||||
});
|
||||
|
||||
test('TernarySearchTree (URI) - lookup', function () {
|
||||
|
||||
const map = new TernarySearchTree<URI, number>(new UriIterator());
|
||||
map.set(URI.parse('http://foo.bar/user/foo/bar'), 1);
|
||||
map.set(URI.parse('http://foo.bar/user/foo?query'), 2);
|
||||
map.set(URI.parse('http://foo.bar/user/foo?QUERY'), 3);
|
||||
map.set(URI.parse('http://foo.bar/user/foo/flip/flop'), 3);
|
||||
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/foo')), undefined);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user')), undefined);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user/foo/bar')), 1);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user/foo?query')), 2);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user/foo?Query')), undefined);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user/foo?QUERY')), 3);
|
||||
assert.equal(map.get(URI.parse('http://foo.bar/user/foo/bar/boo')), undefined);
|
||||
});
|
||||
|
||||
test('TernarySearchTree (PathSegments) - superstr', function () {
|
||||
|
||||
const map = new TernarySearchTree<URI, number>(new UriIterator());
|
||||
map.set(URI.file('/user/foo/bar'), 1);
|
||||
map.set(URI.file('/user/foo'), 2);
|
||||
map.set(URI.file('/user/foo/flip/flop'), 3);
|
||||
map.set(URI.file('/usr/foo'), 4);
|
||||
|
||||
let item: IteratorResult<number>;
|
||||
let iter = map.findSuperstr(URI.file('/user'))!;
|
||||
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 2);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 1);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 3);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, undefined);
|
||||
assert.equal(item.done, true);
|
||||
|
||||
iter = map.findSuperstr(URI.file('/usr'))!;
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 4);
|
||||
assert.equal(item.done, false);
|
||||
|
||||
item = iter.next();
|
||||
assert.equal(item.value, undefined);
|
||||
assert.equal(item.done, true);
|
||||
|
||||
iter = map.findSuperstr(URI.file('/'))!;
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 2);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 1);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 3);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, 4);
|
||||
assert.equal(item.done, false);
|
||||
item = iter.next();
|
||||
assert.equal(item.value, undefined);
|
||||
assert.equal(item.done, true);
|
||||
|
||||
assert.equal(map.findSuperstr(URI.file('/not')), undefined);
|
||||
assert.equal(map.findSuperstr(URI.file('/us')), undefined);
|
||||
assert.equal(map.findSuperstr(URI.file('/usrr')), undefined);
|
||||
assert.equal(map.findSuperstr(URI.file('/userr')), undefined);
|
||||
});
|
||||
|
||||
|
||||
test('ResourceMap - basics', function () {
|
||||
const map = new ResourceMap<any>();
|
||||
|
||||
|
||||
@@ -81,6 +81,27 @@ suite('Strings', () => {
|
||||
assertCompareIgnoreCase('O', '/');
|
||||
});
|
||||
|
||||
test('compareIgnoreCase (substring)', () => {
|
||||
|
||||
function assertCompareIgnoreCase(a: string, b: string, aStart: number, aEnd: number, bStart: number, bEnd: number, recurse = true): void {
|
||||
let actual = strings.compareIgnoreCase(a, b, aStart, aEnd, bStart, bEnd);
|
||||
actual = actual > 0 ? 1 : actual < 0 ? -1 : actual;
|
||||
|
||||
let expected = strings.compare(a.toLowerCase().substring(aStart, aEnd), b.toLowerCase().substring(bStart, bEnd));
|
||||
expected = expected > 0 ? 1 : expected < 0 ? -1 : expected;
|
||||
assert.equal(actual, expected, `${a} <> ${b}`);
|
||||
|
||||
if (recurse) {
|
||||
assertCompareIgnoreCase(b, a, bStart, bEnd, aStart, aEnd, false);
|
||||
}
|
||||
}
|
||||
|
||||
assertCompareIgnoreCase('', '', 0, 0, 0, 0);
|
||||
assertCompareIgnoreCase('abc', 'ABC', 0, 1, 0, 1);
|
||||
assertCompareIgnoreCase('abc', 'Aabc', 0, 3, 1, 4);
|
||||
assertCompareIgnoreCase('abcABc', 'ABcd', 3, 6, 0, 4);
|
||||
});
|
||||
|
||||
test('format', () => {
|
||||
assert.strictEqual(strings.format('Foo Bar'), 'Foo Bar');
|
||||
assert.strictEqual(strings.format('Foo {0} Bar'), 'Foo {0} Bar');
|
||||
|
||||
@@ -538,7 +538,7 @@ suite('URI', () => {
|
||||
assert.throws(() => assertJoined(('foo:'), 'bazz', ''));
|
||||
assert.throws(() => new URL('bazz', 'foo:'));
|
||||
assert.throws(() => assertJoined(('foo://bar'), 'bazz', ''));
|
||||
// assert.throws(() => new URL('bazz', 'foo://bar')); Edge,Chrome => throw, Safari => foo://bar/bazz, Firefox ??
|
||||
// assert.throws(() => new URL('bazz', 'foo://bar')); Edge, Chrome => THROW, Firefox, Safari => foo://bar/bazz
|
||||
});
|
||||
|
||||
test('URI#joinPath (posix)', function () {
|
||||
@@ -549,8 +549,8 @@ suite('URI', () => {
|
||||
assertJoined(('file://server/share/c:/'), '../../bazz', 'file://server/bazz', false);
|
||||
assertJoined(('file://server/share/c:'), '../../bazz', 'file://server/bazz', false);
|
||||
|
||||
assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/bazz');
|
||||
assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/bazz');
|
||||
assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/bazz', false); // Firefox -> Different, Edge, Chrome, Safar -> OK
|
||||
assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/bazz', false); // Firefox -> Different, Edge, Chrome, Safar -> OK
|
||||
});
|
||||
|
||||
test('URI#joinPath (windows)', function () {
|
||||
|
||||
@@ -322,7 +322,11 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
||||
|
||||
// Payload
|
||||
case WorkspaceProvider.QUERY_PARAM_PAYLOAD:
|
||||
payload = JSON.parse(value);
|
||||
try {
|
||||
payload = JSON.parse(value);
|
||||
} catch (error) {
|
||||
console.error(error); // possible invalid JSON
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,14 +17,13 @@ import { escape } from 'vs/base/common/strings';
|
||||
import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { createChannelSender } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { normalizeGitHubUrl } from 'vs/code/common/issue/issueReporterUtil';
|
||||
import { normalizeGitHubUrl } from 'vs/platform/issue/common/issueReporterUtil';
|
||||
import { IssueReporterData as IssueReporterModelData, IssueReporterModel } from 'vs/code/electron-browser/issue/issueReporterModel';
|
||||
import BaseHtml from 'vs/code/electron-browser/issue/issueReporterPage';
|
||||
import 'vs/css!./media/issueReporter';
|
||||
import { localize } from 'vs/nls';
|
||||
import { isRemoteDiagnosticError, SystemInfo } from 'vs/platform/diagnostics/common/diagnostics';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { EnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IMainProcessService, MainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
|
||||
@@ -63,7 +62,7 @@ export function startup(configuration: IssueReporterConfiguration) {
|
||||
}
|
||||
|
||||
export class IssueReporter extends Disposable {
|
||||
private environmentService!: IEnvironmentService;
|
||||
private environmentService!: INativeEnvironmentService;
|
||||
private telemetryService!: ITelemetryService;
|
||||
private logService!: ILogService;
|
||||
private readonly issueReporterModel: IssueReporterModel;
|
||||
|
||||
@@ -169,6 +169,13 @@ ${this.getInfos()}
|
||||
|Screen Reader|${this._data.systemInfo.screenReader}|
|
||||
|VM|${this._data.systemInfo.vmHint}|`;
|
||||
|
||||
if (this._data.systemInfo.linuxEnv) {
|
||||
md += `\n|DESKTOP_SESSION|${this._data.systemInfo.linuxEnv.desktopSession}|
|
||||
|XDG_CURRENT_DESKTOP|${this._data.systemInfo.linuxEnv.xdgCurrentDesktop}|
|
||||
|XDG_SESSION_DESKTOP|${this._data.systemInfo.linuxEnv.xdgSessionDesktop}|
|
||||
|XDG_SESSION_TYPE|${this._data.systemInfo.linuxEnv.xdgSessionType}|`;
|
||||
}
|
||||
|
||||
this._data.systemInfo.remoteData.forEach(remote => {
|
||||
if (isRemoteDiagnosticError(remote)) {
|
||||
md += `\n\n${remote.errorMessage}`;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IssueReporterModel } from 'vs/code/electron-browser/issue/issueReporterModel';
|
||||
import { normalizeGitHubUrl } from 'vs/code/common/issue/issueReporterUtil';
|
||||
import { normalizeGitHubUrl } from 'vs/platform/issue/common/issueReporterUtil';
|
||||
import { IssueType } from 'vs/platform/issue/node/issue';
|
||||
|
||||
suite('IssueReporter', () => {
|
||||
@@ -81,7 +81,56 @@ OS version: undefined
|
||||
<!-- generated by issue reporter -->`);
|
||||
});
|
||||
|
||||
test.skip('serializes remote information when data is provided', () => { //{{SQL CARBON EDIT}} skip test
|
||||
test.skip('serializes Linux environment information when data is provided', () => { //{{SQL CARBON EDIT}} skip test
|
||||
const issueReporterModel = new IssueReporterModel({
|
||||
issueType: 0,
|
||||
systemInfo: {
|
||||
os: 'Darwin',
|
||||
cpus: 'Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)',
|
||||
memory: '16.00GB',
|
||||
vmHint: '0%',
|
||||
processArgs: '',
|
||||
screenReader: 'no',
|
||||
remoteData: [],
|
||||
gpuStatus: {},
|
||||
linuxEnv: {
|
||||
desktopSession: 'ubuntu',
|
||||
xdgCurrentDesktop: 'ubuntu',
|
||||
xdgSessionDesktop: 'ubuntu:GNOME',
|
||||
xdgSessionType: 'x11'
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.equal(issueReporterModel.serialize(),
|
||||
`
|
||||
Issue Type: <b>Bug</b>
|
||||
|
||||
undefined
|
||||
|
||||
VS Code version: undefined
|
||||
OS version: undefined
|
||||
|
||||
<details>
|
||||
<summary>System Info</summary>
|
||||
|
||||
|Item|Value|
|
||||
|---|---|
|
||||
|CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)|
|
||||
|GPU Status||
|
||||
|Load (avg)|undefined|
|
||||
|Memory (System)|16.00GB|
|
||||
|Process Argv||
|
||||
|Screen Reader|no|
|
||||
|VM|0%|
|
||||
|DESKTOP_SESSION|ubuntu|
|
||||
|XDG_CURRENT_DESKTOP|ubuntu|
|
||||
|XDG_SESSION_DESKTOP|ubuntu:GNOME|
|
||||
|XDG_SESSION_TYPE|x11|
|
||||
</details>Extensions: none
|
||||
<!-- generated by issue reporter -->`);
|
||||
});
|
||||
|
||||
test.skip('serializes remote information when data is provided', () => { //{{SQL CARBON EDIT}} skip test
|
||||
const issueReporterModel = new IssueReporterModel({
|
||||
issueType: 0,
|
||||
systemInfo: {
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
interface ExtensionEntry {
|
||||
@@ -33,7 +33,7 @@ interface LanguagePackFile {
|
||||
export class LanguagePackCachedDataCleaner extends Disposable {
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly _environmentService: INativeEnvironmentService,
|
||||
@ILogService private readonly _logService: ILogService
|
||||
) {
|
||||
super();
|
||||
@@ -102,4 +102,4 @@ export class LanguagePackCachedDataCleaner extends Disposable {
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { readdir, rimraf, stat } from 'vs/base/node/pfs';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
|
||||
export class NodeCachedDataCleaner {
|
||||
@@ -19,7 +20,7 @@ export class NodeCachedDataCleaner {
|
||||
private readonly _disposables = new DisposableStore();
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService private readonly _environmentService: IEnvironmentService
|
||||
@IEnvironmentService private readonly _environmentService: INativeEnvironmentService
|
||||
) {
|
||||
this._manageCachedDataSoon();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { readdir, readFile, rimraf } from 'vs/base/node/pfs';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
@@ -16,7 +17,7 @@ export class StorageDataCleaner extends Disposable {
|
||||
private static readonly NON_EMPTY_WORKSPACE_ID_LENGTH = 128 / 4;
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
||||
@@ -10,10 +10,11 @@ import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementChannel, ExtensionTipsChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -68,6 +69,7 @@ import { IAuthenticationTokenService, AuthenticationTokenService } from 'vs/plat
|
||||
import { AuthenticationTokenServiceChannel } from 'vs/platform/authentication/common/authenticationIpc';
|
||||
import { UserDataSyncBackupStoreService } from 'vs/platform/userDataSync/common/userDataSyncBackupStoreService';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
import { ExtensionTipsService } from 'vs/platform/extensionManagement/node/extensionTipsService';
|
||||
|
||||
export interface ISharedProcessConfiguration {
|
||||
readonly machineId: string;
|
||||
@@ -160,14 +162,13 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
|
||||
let telemetryService: ITelemetryService;
|
||||
instantiationService.invokeFunction(accessor => {
|
||||
const services = new ServiceCollection();
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const { appRoot, extensionsPath, extensionDevelopmentLocationURI, isBuilt, installSourcePath } = environmentService;
|
||||
const telemetryLogService = new FollowerLogService(loggerClient, new SpdLogService('telemetry', environmentService.logsPath, initData.logLevel));
|
||||
telemetryLogService.info('The below are logs for every telemetry event sent from VS Code once the log level is set to trace.');
|
||||
telemetryLogService.info('===========================================================');
|
||||
|
||||
let appInsightsAppender: ITelemetryAppender | null = NullAppender;
|
||||
if (!extensionDevelopmentLocationURI && !environmentService.args['disable-telemetry'] && product.enableTelemetry) {
|
||||
if (!extensionDevelopmentLocationURI && !environmentService.disableTelemetry && product.enableTelemetry) {
|
||||
if (product.aiConfig && product.aiConfig.asimovKey && isBuilt) {
|
||||
appInsightsAppender = new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey, telemetryLogService);
|
||||
disposables.add(toDisposable(() => appInsightsAppender!.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||
@@ -190,6 +191,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
|
||||
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
|
||||
services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
|
||||
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService));
|
||||
services.set(IExtensionTipsService, new SyncDescriptor(ExtensionTipsService));
|
||||
|
||||
services.set(ICredentialsService, new SyncDescriptor(KeytarCredentialsService));
|
||||
services.set(IAuthenticationTokenService, new SyncDescriptor(AuthenticationTokenService));
|
||||
@@ -218,6 +220,10 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
|
||||
const diagnosticsChannel = new DiagnosticsChannel(diagnosticsService);
|
||||
server.registerChannel('diagnostics', diagnosticsChannel);
|
||||
|
||||
const extensionTipsService = accessor.get(IExtensionTipsService);
|
||||
const extensionTipsChannel = new ExtensionTipsChannel(extensionTipsService);
|
||||
server.registerChannel('extensionTipsService', extensionTipsChannel);
|
||||
|
||||
const authTokenService = accessor.get(IAuthenticationTokenService);
|
||||
const authTokenChannel = new AuthenticationTokenServiceChannel(authTokenService);
|
||||
server.registerChannel('authToken', authTokenChannel);
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow } from 'electron';
|
||||
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
|
||||
import { WindowsMainService } from 'vs/platform/windows/electron-main/windowsMainService';
|
||||
import { OpenContext, IWindowOpenable } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
|
||||
import { OpenContext } from 'vs/platform/windows/node/window';
|
||||
import { ActiveWindowManager } from 'vs/code/node/activeWindowTracker';
|
||||
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { getShellEnvironment } from 'vs/code/node/shellEnv';
|
||||
@@ -78,6 +79,7 @@ import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
import { StorageKeysSyncRegistryChannel } from 'vs/platform/userDataSync/common/userDataSyncIpc';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
|
||||
export class CodeApplication extends Disposable {
|
||||
private windowsMainService: IWindowsMainService | undefined;
|
||||
@@ -88,7 +90,7 @@ export class CodeApplication extends Disposable {
|
||||
private readonly userEnv: IProcessEnvironment,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IStateService private readonly stateService: IStateService
|
||||
@@ -588,12 +590,11 @@ export class CodeApplication extends Disposable {
|
||||
this.dialogMainService = accessor.get(IDialogMainService);
|
||||
|
||||
// Check for initial URLs to handle from protocol link invocations
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const pendingWindowOpenablesFromProtocolLinks: IWindowOpenable[] = [];
|
||||
const pendingProtocolLinksToHandle = coalesce([
|
||||
|
||||
// Windows/Linux: protocol handler invokes CLI with --open-url
|
||||
...environmentService.args['open-url'] ? environmentService.args._urls || [] : [],
|
||||
...this.environmentService.args['open-url'] ? this.environmentService.args._urls || [] : [],
|
||||
|
||||
// macOS: open-url events
|
||||
...((<any>global).getOpenUrls() || []) as string[]
|
||||
@@ -619,6 +620,7 @@ export class CodeApplication extends Disposable {
|
||||
|
||||
// Create a URL handler to open file URIs in the active window
|
||||
const app = this;
|
||||
const environmentService = this.environmentService;
|
||||
urlService.registerHandler({
|
||||
async handleURL(uri: URI): Promise<boolean> {
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import 'vs/platform/update/common/update.config.contribution';
|
||||
import { app, dialog } from 'electron';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { isWindows, IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { parseMainProcessArgv, addArg } from 'vs/platform/environment/node/argvHelper';
|
||||
@@ -23,8 +22,9 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ILogService, ConsoleLogMainService, MultiplexLogService, getLogLevel } from 'vs/platform/log/common/log';
|
||||
import { StateService } from 'vs/platform/state/node/stateService';
|
||||
import { IStateService } from 'vs/platform/state/node/state';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService, xdgRuntimeDir } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { EnvironmentService, xdgRuntimeDir, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
|
||||
import { IRequestService } from 'vs/platform/request/common/request';
|
||||
@@ -98,12 +98,11 @@ class CodeMain {
|
||||
// log file access on Windows (https://github.com/Microsoft/vscode/issues/41218)
|
||||
const bufferLogService = new BufferLogService();
|
||||
|
||||
const [instantiationService, instanceEnvironment] = this.createServices(args, bufferLogService);
|
||||
const [instantiationService, instanceEnvironment, environmentService] = this.createServices(args, bufferLogService);
|
||||
try {
|
||||
|
||||
// Init services
|
||||
await instantiationService.invokeFunction(async accessor => {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
const stateService = accessor.get(IStateService);
|
||||
|
||||
@@ -120,13 +119,12 @@ class CodeMain {
|
||||
|
||||
// Startup
|
||||
await instantiationService.invokeFunction(async accessor => {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const logService = accessor.get(ILogService);
|
||||
const lifecycleMainService = accessor.get(ILifecycleMainService);
|
||||
const fileService = accessor.get(IFileService);
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
|
||||
const mainIpcServer = await this.doStartup(logService, environmentService, lifecycleMainService, instantiationService, true);
|
||||
const mainIpcServer = await this.doStartup(args, logService, environmentService, lifecycleMainService, instantiationService, true);
|
||||
|
||||
bufferLogService.logger = new SpdLogService('main', environmentService.logsPath, bufferLogService.getLevel());
|
||||
once(lifecycleMainService.onWillShutdown)(() => {
|
||||
@@ -141,7 +139,7 @@ class CodeMain {
|
||||
}
|
||||
}
|
||||
|
||||
private createServices(args: ParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment] {
|
||||
private createServices(args: ParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment, INativeEnvironmentService] {
|
||||
const services = new ServiceCollection();
|
||||
|
||||
const environmentService = new EnvironmentService(args, process.execPath);
|
||||
@@ -165,10 +163,10 @@ class CodeMain {
|
||||
services.set(ISignService, new SyncDescriptor(SignService));
|
||||
services.set(IStorageKeysSyncRegistryService, new SyncDescriptor(StorageKeysSyncRegistryService));
|
||||
|
||||
return [new InstantiationService(services, true), instanceEnvironment];
|
||||
return [new InstantiationService(services, true), instanceEnvironment, environmentService];
|
||||
}
|
||||
|
||||
private initServices(environmentService: IEnvironmentService, configurationService: ConfigurationService, stateService: StateService): Promise<unknown> {
|
||||
private initServices(environmentService: INativeEnvironmentService, configurationService: ConfigurationService, stateService: StateService): Promise<unknown> {
|
||||
|
||||
// Environment service (paths)
|
||||
const environmentServiceInitialization = Promise.all<void | undefined>([
|
||||
@@ -189,7 +187,7 @@ class CodeMain {
|
||||
return Promise.all([environmentServiceInitialization, configurationServiceInitialization, stateServiceInitialization]);
|
||||
}
|
||||
|
||||
private patchEnvironment(environmentService: IEnvironmentService): IProcessEnvironment {
|
||||
private patchEnvironment(environmentService: INativeEnvironmentService): IProcessEnvironment {
|
||||
const instanceEnvironment: IProcessEnvironment = {
|
||||
VSCODE_IPC_HOOK: environmentService.mainIPCHandle
|
||||
};
|
||||
@@ -201,12 +199,12 @@ class CodeMain {
|
||||
}
|
||||
});
|
||||
|
||||
assign(process.env, instanceEnvironment);
|
||||
Object.assign(process.env, instanceEnvironment);
|
||||
|
||||
return instanceEnvironment;
|
||||
}
|
||||
|
||||
private async doStartup(logService: ILogService, environmentService: IEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {
|
||||
private async doStartup(args: ParsedArgs, logService: ILogService, environmentService: INativeEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {
|
||||
|
||||
// Try to setup a server for running. If that succeeds it means
|
||||
// we are the first instance to startup. Otherwise it is likely
|
||||
@@ -262,7 +260,7 @@ class CodeMain {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return this.doStartup(logService, environmentService, lifecycleMainService, instantiationService, false);
|
||||
return this.doStartup(args, logService, environmentService, lifecycleMainService, instantiationService, false);
|
||||
}
|
||||
|
||||
// Tests from CLI require to be the only instance currently
|
||||
@@ -278,7 +276,7 @@ class CodeMain {
|
||||
// Skip this if we are running with --wait where it is expected that we wait for a while.
|
||||
// Also skip when gathering diagnostics (--status) which can take a longer time.
|
||||
let startupWarningDialogHandle: NodeJS.Timeout | undefined = undefined;
|
||||
if (!environmentService.args.wait && !environmentService.args.status) {
|
||||
if (!args.wait && !args.status) {
|
||||
startupWarningDialogHandle = setTimeout(() => {
|
||||
this.showStartupWarningDialog(
|
||||
localize('secondInstanceNoResponse', "Another instance of {0} is running but not responding", product.nameShort),
|
||||
@@ -290,7 +288,7 @@ class CodeMain {
|
||||
const launchService = createChannelSender<ILaunchMainService>(client.getChannel('launch'), { disableMarshalling: true });
|
||||
|
||||
// Process Info
|
||||
if (environmentService.args.status) {
|
||||
if (args.status) {
|
||||
return instantiationService.invokeFunction(async accessor => {
|
||||
// Create a diagnostic service connected to the existing shared process
|
||||
const sharedProcessClient = await connect(environmentService.sharedIPCHandle, 'main');
|
||||
@@ -312,7 +310,7 @@ class CodeMain {
|
||||
|
||||
// Send environment over...
|
||||
logService.trace('Sending env to running instance...');
|
||||
await launchService.start(environmentService.args, process.env as IProcessEnvironment);
|
||||
await launchService.start(args, process.env as IProcessEnvironment);
|
||||
|
||||
// Cleanup
|
||||
client.dispose();
|
||||
@@ -326,7 +324,7 @@ class CodeMain {
|
||||
}
|
||||
|
||||
// Print --status usage info
|
||||
if (environmentService.args.status) {
|
||||
if (args.status) {
|
||||
logService.warn('Warning: The --status argument can only be used if Code is already running. Please run it again after Code has started.');
|
||||
|
||||
throw new ExpectedError('Terminating...');
|
||||
@@ -344,7 +342,7 @@ class CodeMain {
|
||||
return server;
|
||||
}
|
||||
|
||||
private handleStartupDataDirError(environmentService: IEnvironmentService, error: NodeJS.ErrnoException): void {
|
||||
private handleStartupDataDirError(environmentService: INativeEnvironmentService, error: NodeJS.ErrnoException): void {
|
||||
if (error.code === 'EACCES' || error.code === 'EPERM') {
|
||||
const directories = [environmentService.userDataPath];
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { BrowserWindow, ipcMain, WebContents, Event as ElectronEvent } from 'electron';
|
||||
@@ -14,6 +13,7 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec
|
||||
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
|
||||
import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
|
||||
export class SharedProcess implements ISharedProcess {
|
||||
|
||||
@@ -26,7 +26,7 @@ export class SharedProcess implements ISharedProcess {
|
||||
constructor(
|
||||
private readonly machineId: string,
|
||||
private userEnv: NodeJS.ProcessEnv,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IThemeMainService private readonly themeMainService: IThemeMainService
|
||||
@@ -47,13 +47,13 @@ export class SharedProcess implements ISharedProcess {
|
||||
disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer
|
||||
}
|
||||
});
|
||||
const config = assign({
|
||||
const config = {
|
||||
appRoot: this.environmentService.appRoot,
|
||||
machineId: this.machineId,
|
||||
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
|
||||
userEnv: this.userEnv,
|
||||
windowId: this.window.id
|
||||
});
|
||||
};
|
||||
|
||||
const url = `${require.toUrl('vs/code/electron-browser/sharedProcess/sharedProcess.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
|
||||
this.window.loadURL(url);
|
||||
|
||||
@@ -9,12 +9,13 @@ import * as nls from 'vs/nls';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme } from 'electron';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { parseArgs, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IWindowSettings, MenuBarVisibility, ReadyState, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowSettings, MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
|
||||
@@ -60,6 +61,29 @@ const enum WindowError {
|
||||
CRASHED = 2
|
||||
}
|
||||
|
||||
const enum ReadyState {
|
||||
|
||||
/**
|
||||
* This window has not loaded any HTML yet
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* This window is loading HTML
|
||||
*/
|
||||
LOADING,
|
||||
|
||||
/**
|
||||
* This window is navigating to another HTML
|
||||
*/
|
||||
NAVIGATING,
|
||||
|
||||
/**
|
||||
* This window is done loading HTML
|
||||
*/
|
||||
READY
|
||||
}
|
||||
|
||||
export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
private static readonly MIN_WIDTH = 600;
|
||||
@@ -97,7 +121,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
constructor(
|
||||
config: IWindowCreationOptions,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IStorageMainService private readonly storageService: IStorageMainService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@@ -471,7 +495,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
// Inject headers when requests are incoming
|
||||
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];
|
||||
this._win.webContents.session.webRequest.onBeforeSendHeaders({ urls }, (details, cb) =>
|
||||
this.marketplaceHeadersPromise.then(headers => cb({ cancel: false, requestHeaders: objects.assign(details.requestHeaders, headers) as Record<string, string> })));
|
||||
this.marketplaceHeadersPromise.then(headers => cb({ cancel: false, requestHeaders: Object.assign(details.requestHeaders, headers) })));
|
||||
}
|
||||
|
||||
private onWindowError(error: WindowError): void {
|
||||
@@ -597,7 +621,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
// Add disable-extensions to the config, but do not preserve it on currentConfig or
|
||||
// pendingLoadConfig so that it is applied only on this load
|
||||
const configuration = objects.assign({}, config);
|
||||
const configuration = { ...config };
|
||||
if (disableExtensions !== undefined) {
|
||||
configuration['disable-extensions'] = disableExtensions;
|
||||
}
|
||||
@@ -701,7 +725,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
// Config (combination of process.argv and window configuration)
|
||||
const environment = parseArgs(process.argv, OPTIONS);
|
||||
const config = objects.assign(environment, windowConfiguration);
|
||||
const config = Object.assign(environment, windowConfiguration);
|
||||
for (const key in config) {
|
||||
const configValue = (config as any)[key];
|
||||
if (configValue === undefined || configValue === null || configValue === '' || configValue === false) {
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import { spawn, ChildProcess, SpawnOptions } from 'child_process';
|
||||
import { buildHelpMessage, buildVersionMessage, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { buildHelpMessage, buildVersionMessage, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { parseCLIProcessArgv, addArg } from 'vs/platform/environment/node/argvHelper';
|
||||
import { createWaitMarkerFile } from 'vs/platform/environment/node/waitMarkerFile';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import * as paths from 'vs/base/common/path';
|
||||
import { whenDeleted, writeFileSync } from 'vs/base/node/pfs';
|
||||
|
||||
@@ -7,13 +7,13 @@ import { localize } from 'vs/nls';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as semver from 'semver-umd';
|
||||
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { EnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, IGalleryExtension, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
@@ -49,7 +49,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
|
||||
|
||||
const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id);
|
||||
const notInstalled = (id: string) => localize('notInstalled', "Extension '{0}' is not installed.", id);
|
||||
const useId = localize('useId', "Make sure you use the full extension ID, including the publisher, e.g.: {0}", 'ms-vscode.csharp');
|
||||
const useId = localize('useId', "Make sure you use the full extension ID, including the publisher, e.g.: {0}", 'ms-dotnettools.csharp');
|
||||
|
||||
function getId(manifest: IExtensionManifest, withVersion?: boolean): string {
|
||||
if (withVersion) {
|
||||
@@ -74,7 +74,7 @@ export class Main {
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
|
||||
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService
|
||||
) { }
|
||||
@@ -328,21 +328,17 @@ export async function main(argv: ParsedArgs): Promise<void> {
|
||||
const instantiationService: IInstantiationService = new InstantiationService(services);
|
||||
|
||||
return instantiationService.invokeFunction(async accessor => {
|
||||
const envService = accessor.get(IEnvironmentService);
|
||||
const stateService = accessor.get(IStateService);
|
||||
|
||||
const { appRoot, extensionsPath, extensionDevelopmentLocationURI, isBuilt, installSourcePath } = envService;
|
||||
const { appRoot, extensionsPath, extensionDevelopmentLocationURI, isBuilt, installSourcePath } = environmentService;
|
||||
|
||||
const services = new ServiceCollection();
|
||||
|
||||
|
||||
services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
|
||||
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
|
||||
|
||||
const appenders: AppInsightsAppender[] = [];
|
||||
if (isBuilt && !extensionDevelopmentLocationURI && !envService.args['disable-telemetry'] && product.enableTelemetry) {
|
||||
|
||||
if (isBuilt && !extensionDevelopmentLocationURI && !environmentService.disableTelemetry && product.enableTelemetry) {
|
||||
if (product.aiConfig && product.aiConfig.asimovKey) {
|
||||
appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey, logService));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as strings from 'vs/base/common/strings';
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
|
||||
export function validatePaths(args: ParsedArgs): ParsedArgs {
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as cp from 'child_process';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
|
||||
function getUnixShellEnvironment(logService: ILogService): Promise<typeof process.env> {
|
||||
const promise = new Promise<typeof process.env>((resolve, reject) => {
|
||||
@@ -21,10 +20,11 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
|
||||
const mark = generateUuid().replace(/-/g, '').substr(0, 12);
|
||||
const regex = new RegExp(mark + '(.*)' + mark);
|
||||
|
||||
const env = assign({}, process.env, {
|
||||
const env = {
|
||||
...process.env,
|
||||
ELECTRON_RUN_AS_NODE: '1',
|
||||
ELECTRON_NO_ATTACH_CONSOLE: '1'
|
||||
});
|
||||
};
|
||||
|
||||
const command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`;
|
||||
logService.trace('getUnixShellEnvironment#env', env);
|
||||
@@ -90,7 +90,7 @@ let _shellEnv: Promise<typeof process.env>;
|
||||
* This should only be done when Code itself is not launched
|
||||
* from within a shell.
|
||||
*/
|
||||
export function getShellEnvironment(logService: ILogService, environmentService: IEnvironmentService): Promise<typeof process.env> {
|
||||
export function getShellEnvironment(logService: ILogService, environmentService: INativeEnvironmentService): Promise<typeof process.env> {
|
||||
if (_shellEnv === undefined) {
|
||||
if (environmentService.args['disable-user-env-probe']) {
|
||||
logService.trace('getShellEnvironment: disable-user-env-probe set, skipping');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMarkerService, IMarker, MarkerSeverity, MarkerTag } from 'vs/platform/markers/common/markers';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, toDisposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IModelDeltaDecoration, ITextModel, IModelDecorationOptions, TrackedRangeStickiness, OverviewRulerLane, IModelDecoration, MinimapPosition, IModelDecorationMinimapOptions } from 'vs/editor/common/model';
|
||||
import { ClassName } from 'vs/editor/common/model/intervalTree';
|
||||
@@ -37,6 +37,10 @@ class MarkerDecorations extends Disposable {
|
||||
}));
|
||||
}
|
||||
|
||||
register<T extends IDisposable>(t: T): T {
|
||||
return super._register(t);
|
||||
}
|
||||
|
||||
public update(markers: IMarker[], newDecorations: IModelDeltaDecoration[]): void {
|
||||
const oldIds = keys(this._markersData);
|
||||
this._markersData.clear();
|
||||
@@ -110,6 +114,7 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
|
||||
private _onModelAdded(model: ITextModel): void {
|
||||
const markerDecorations = new MarkerDecorations(model);
|
||||
this._markerDecorations.set(MODEL_ID(model.uri), markerDecorations);
|
||||
markerDecorations.register(model.onDidChangeContent(() => this._updateDecorations(markerDecorations)));
|
||||
this._updateDecorations(markerDecorations);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export const editorActiveLineNumber = registerColor('editorLineNumber.activeFore
|
||||
|
||||
export const editorRuler = registerColor('editorRuler.foreground', { dark: '#5A5A5A', light: Color.lightgrey, hc: Color.white }, nls.localize('editorRuler', 'Color of the editor rulers.'));
|
||||
|
||||
export const editorCodeLensForeground = registerColor('editorCodeLens.foreground', { dark: '#999999', light: '#999999', hc: '#999999' }, nls.localize('editorCodeLensForeground', 'Foreground color of editor code lenses'));
|
||||
export const editorCodeLensForeground = registerColor('editorCodeLens.foreground', { dark: '#999999', light: '#999999', hc: '#999999' }, nls.localize('editorCodeLensForeground', 'Foreground color of editor CodeLens'));
|
||||
|
||||
export const editorBracketMatchBackground = registerColor('editorBracketMatch.background', { dark: '#0064001a', light: '#0064001a', hc: '#0064001a' }, nls.localize('editorBracketMatchBackground', 'Background color behind matching brackets'));
|
||||
export const editorBracketMatchBorder = registerColor('editorBracketMatch.border', { dark: '#888', light: '#B9B9B9', hc: contrastBorder }, nls.localize('editorBracketMatchBorder', 'Color for matching brackets boxes'));
|
||||
|
||||
@@ -419,8 +419,8 @@ registerEditorAction(class ShowLensesInCurrentLine extends EditorAction {
|
||||
super({
|
||||
id: 'codelens.showLensesInCurrentLine',
|
||||
precondition: EditorContextKeys.hasCodeLensProvider,
|
||||
label: localize('showLensOnLine', "Show Code Lens Commands For Current Line"),
|
||||
alias: 'Show Code Lens Commands For Current Line',
|
||||
label: localize('showLensOnLine', "Show CodeLens Commands For Current Line"),
|
||||
alias: 'Show CodeLens Commands For Current Line',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -540,168 +540,168 @@ registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) =
|
||||
|
||||
const symbolIconArrayColor = theme.getColor(SYMBOL_ICON_ARRAY_FOREGROUND);
|
||||
if (symbolIconArrayColor) {
|
||||
collector.addRule(`.codicon-symbol-array { color: ${symbolIconArrayColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-array { color: ${symbolIconArrayColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconBooleanColor = theme.getColor(SYMBOL_ICON_BOOLEAN_FOREGROUND);
|
||||
if (symbolIconBooleanColor) {
|
||||
collector.addRule(`.codicon-symbol-boolean { color: ${symbolIconBooleanColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-boolean { color: ${symbolIconBooleanColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconClassColor = theme.getColor(SYMBOL_ICON_CLASS_FOREGROUND);
|
||||
if (symbolIconClassColor) {
|
||||
collector.addRule(`.codicon-symbol-class { color: ${symbolIconClassColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-class { color: ${symbolIconClassColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconMethodColor = theme.getColor(SYMBOL_ICON_METHOD_FOREGROUND);
|
||||
if (symbolIconMethodColor) {
|
||||
collector.addRule(`.codicon-symbol-method { color: ${symbolIconMethodColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-method { color: ${symbolIconMethodColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconColorColor = theme.getColor(SYMBOL_ICON_COLOR_FOREGROUND);
|
||||
if (symbolIconColorColor) {
|
||||
collector.addRule(`.codicon-symbol-color { color: ${symbolIconColorColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-color { color: ${symbolIconColorColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconConstantColor = theme.getColor(SYMBOL_ICON_CONSTANT_FOREGROUND);
|
||||
if (symbolIconConstantColor) {
|
||||
collector.addRule(`.codicon-symbol-constant { color: ${symbolIconConstantColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-constant { color: ${symbolIconConstantColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconConstructorColor = theme.getColor(SYMBOL_ICON_CONSTRUCTOR_FOREGROUND);
|
||||
if (symbolIconConstructorColor) {
|
||||
collector.addRule(`.codicon-symbol-constructor { color: ${symbolIconConstructorColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-constructor { color: ${symbolIconConstructorColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconEnumeratorColor = theme.getColor(SYMBOL_ICON_ENUMERATOR_FOREGROUND);
|
||||
if (symbolIconEnumeratorColor) {
|
||||
collector.addRule(`
|
||||
.codicon-symbol-value,.codicon-symbol-enum { color: ${symbolIconEnumeratorColor} !important; }`);
|
||||
.monaco-workbench .codicon-symbol-value,.monaco-workbench .codicon-symbol-enum { color: ${symbolIconEnumeratorColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconEnumeratorMemberColor = theme.getColor(SYMBOL_ICON_ENUMERATOR_MEMBER_FOREGROUND);
|
||||
if (symbolIconEnumeratorMemberColor) {
|
||||
collector.addRule(`.codicon-symbol-enum-member { color: ${symbolIconEnumeratorMemberColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-enum-member { color: ${symbolIconEnumeratorMemberColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconEventColor = theme.getColor(SYMBOL_ICON_EVENT_FOREGROUND);
|
||||
if (symbolIconEventColor) {
|
||||
collector.addRule(`.codicon-symbol-event { color: ${symbolIconEventColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-event { color: ${symbolIconEventColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconFieldColor = theme.getColor(SYMBOL_ICON_FIELD_FOREGROUND);
|
||||
if (symbolIconFieldColor) {
|
||||
collector.addRule(`.codicon-symbol-field { color: ${symbolIconFieldColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-field { color: ${symbolIconFieldColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconFileColor = theme.getColor(SYMBOL_ICON_FILE_FOREGROUND);
|
||||
if (symbolIconFileColor) {
|
||||
collector.addRule(`.codicon-symbol-file { color: ${symbolIconFileColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-file { color: ${symbolIconFileColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconFolderColor = theme.getColor(SYMBOL_ICON_FOLDER_FOREGROUND);
|
||||
if (symbolIconFolderColor) {
|
||||
collector.addRule(`.codicon-symbol-folder { color: ${symbolIconFolderColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-folder { color: ${symbolIconFolderColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconFunctionColor = theme.getColor(SYMBOL_ICON_FUNCTION_FOREGROUND);
|
||||
if (symbolIconFunctionColor) {
|
||||
collector.addRule(`.codicon-symbol-function { color: ${symbolIconFunctionColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-function { color: ${symbolIconFunctionColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconInterfaceColor = theme.getColor(SYMBOL_ICON_INTERFACE_FOREGROUND);
|
||||
if (symbolIconInterfaceColor) {
|
||||
collector.addRule(`.codicon-symbol-interface { color: ${symbolIconInterfaceColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-interface { color: ${symbolIconInterfaceColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconKeyColor = theme.getColor(SYMBOL_ICON_KEY_FOREGROUND);
|
||||
if (symbolIconKeyColor) {
|
||||
collector.addRule(`.codicon-symbol-key { color: ${symbolIconKeyColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-key { color: ${symbolIconKeyColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconKeywordColor = theme.getColor(SYMBOL_ICON_KEYWORD_FOREGROUND);
|
||||
if (symbolIconKeywordColor) {
|
||||
collector.addRule(`.codicon-symbol-keyword { color: ${symbolIconKeywordColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-keyword { color: ${symbolIconKeywordColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconModuleColor = theme.getColor(SYMBOL_ICON_MODULE_FOREGROUND);
|
||||
if (symbolIconModuleColor) {
|
||||
collector.addRule(`.codicon-symbol-module { color: ${symbolIconModuleColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-module { color: ${symbolIconModuleColor}; }`);
|
||||
}
|
||||
|
||||
const outlineNamespaceColor = theme.getColor(SYMBOL_ICON_NAMESPACE_FOREGROUND);
|
||||
if (outlineNamespaceColor) {
|
||||
collector.addRule(`.codicon-symbol-namespace { color: ${outlineNamespaceColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-namespace { color: ${outlineNamespaceColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconNullColor = theme.getColor(SYMBOL_ICON_NULL_FOREGROUND);
|
||||
if (symbolIconNullColor) {
|
||||
collector.addRule(`.codicon-symbol-null { color: ${symbolIconNullColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-null { color: ${symbolIconNullColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconNumberColor = theme.getColor(SYMBOL_ICON_NUMBER_FOREGROUND);
|
||||
if (symbolIconNumberColor) {
|
||||
collector.addRule(`.codicon-symbol-number { color: ${symbolIconNumberColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-number { color: ${symbolIconNumberColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconObjectColor = theme.getColor(SYMBOL_ICON_OBJECT_FOREGROUND);
|
||||
if (symbolIconObjectColor) {
|
||||
collector.addRule(`.codicon-symbol-object { color: ${symbolIconObjectColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-object { color: ${symbolIconObjectColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconOperatorColor = theme.getColor(SYMBOL_ICON_OPERATOR_FOREGROUND);
|
||||
if (symbolIconOperatorColor) {
|
||||
collector.addRule(`.codicon-symbol-operator { color: ${symbolIconOperatorColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-operator { color: ${symbolIconOperatorColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconPackageColor = theme.getColor(SYMBOL_ICON_PACKAGE_FOREGROUND);
|
||||
if (symbolIconPackageColor) {
|
||||
collector.addRule(`.codicon-symbol-package { color: ${symbolIconPackageColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-package { color: ${symbolIconPackageColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconPropertyColor = theme.getColor(SYMBOL_ICON_PROPERTY_FOREGROUND);
|
||||
if (symbolIconPropertyColor) {
|
||||
collector.addRule(`.codicon-symbol-property { color: ${symbolIconPropertyColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-property { color: ${symbolIconPropertyColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconReferenceColor = theme.getColor(SYMBOL_ICON_REFERENCE_FOREGROUND);
|
||||
if (symbolIconReferenceColor) {
|
||||
collector.addRule(`.codicon-symbol-reference { color: ${symbolIconReferenceColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-reference { color: ${symbolIconReferenceColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconSnippetColor = theme.getColor(SYMBOL_ICON_SNIPPET_FOREGROUND);
|
||||
if (symbolIconSnippetColor) {
|
||||
collector.addRule(`.codicon-symbol-snippet { color: ${symbolIconSnippetColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-snippet { color: ${symbolIconSnippetColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconStringColor = theme.getColor(SYMBOL_ICON_STRING_FOREGROUND);
|
||||
if (symbolIconStringColor) {
|
||||
collector.addRule(`.codicon-symbol-string { color: ${symbolIconStringColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-string { color: ${symbolIconStringColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconStructColor = theme.getColor(SYMBOL_ICON_STRUCT_FOREGROUND);
|
||||
if (symbolIconStructColor) {
|
||||
collector.addRule(`.codicon-symbol-struct { color: ${symbolIconStructColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-struct { color: ${symbolIconStructColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconTextColor = theme.getColor(SYMBOL_ICON_TEXT_FOREGROUND);
|
||||
if (symbolIconTextColor) {
|
||||
collector.addRule(`.codicon-symbol-text { color: ${symbolIconTextColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-text { color: ${symbolIconTextColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconTypeParameterColor = theme.getColor(SYMBOL_ICON_TYPEPARAMETER_FOREGROUND);
|
||||
if (symbolIconTypeParameterColor) {
|
||||
collector.addRule(`.codicon-symbol-type-parameter { color: ${symbolIconTypeParameterColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-type-parameter { color: ${symbolIconTypeParameterColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconUnitColor = theme.getColor(SYMBOL_ICON_UNIT_FOREGROUND);
|
||||
if (symbolIconUnitColor) {
|
||||
collector.addRule(`.codicon-symbol-unit { color: ${symbolIconUnitColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-unit { color: ${symbolIconUnitColor}; }`);
|
||||
}
|
||||
|
||||
const symbolIconVariableColor = theme.getColor(SYMBOL_ICON_VARIABLE_FOREGROUND);
|
||||
if (symbolIconVariableColor) {
|
||||
collector.addRule(`.codicon-symbol-variable { color: ${symbolIconVariableColor} !important; }`);
|
||||
collector.addRule(`.monaco-workbench .codicon-symbol-variable { color: ${symbolIconVariableColor}; }`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -504,34 +504,33 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
messageElement.innerText = message;
|
||||
|
||||
if (source || code) {
|
||||
if (typeof code === 'string') {
|
||||
// Code has link
|
||||
if (code && typeof code !== 'string') {
|
||||
const sourceAndCodeElement = $('span');
|
||||
if (source) {
|
||||
const sourceElement = dom.append(sourceAndCodeElement, $('span'));
|
||||
sourceElement.innerText = source;
|
||||
}
|
||||
this._codeLink = dom.append(sourceAndCodeElement, $('a.code-link'));
|
||||
this._codeLink.setAttribute('href', code.target.toString());
|
||||
|
||||
this._codeLink.onclick = (e) => {
|
||||
this._openerService.open(code.target);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const codeElement = dom.append(this._codeLink, $('span'));
|
||||
codeElement.innerText = code.value;
|
||||
|
||||
const detailsElement = dom.append(markerElement, sourceAndCodeElement);
|
||||
detailsElement.style.opacity = '0.6';
|
||||
detailsElement.style.paddingLeft = '6px';
|
||||
} else {
|
||||
const detailsElement = dom.append(markerElement, $('span'));
|
||||
detailsElement.style.opacity = '0.6';
|
||||
detailsElement.style.paddingLeft = '6px';
|
||||
detailsElement.innerText = source && code ? `${source}(${code})` : source ? source : `(${code})`;
|
||||
} else {
|
||||
if (code) {
|
||||
const sourceAndCodeElement = $('span');
|
||||
if (source) {
|
||||
const sourceElement = dom.append(sourceAndCodeElement, $('span'));
|
||||
sourceElement.innerText = source;
|
||||
}
|
||||
this._codeLink = dom.append(sourceAndCodeElement, $('a.code-link'));
|
||||
this._codeLink.setAttribute('href', code.target.toString());
|
||||
|
||||
this._codeLink.onclick = (e) => {
|
||||
this._openerService.open(code.target);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const codeElement = dom.append(this._codeLink, $('span'));
|
||||
codeElement.innerText = code.value;
|
||||
|
||||
const detailsElement = dom.append(markerElement, sourceAndCodeElement);
|
||||
detailsElement.style.opacity = '0.6';
|
||||
detailsElement.style.paddingLeft = '6px';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { writeFileSync, writeFile, readFile, readdir, exists, rimraf, rename, Ri
|
||||
import { IBackupMainService, IWorkspaceBackupInfo, isWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup';
|
||||
import { IBackupWorkspacesFormat, IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -32,7 +33,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
private emptyWindows: IEmptyWindowBackupInfo[] = [];
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IEnvironmentService environmentService: INativeEnvironmentService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
this.configuration = configuration || Object.create(null);
|
||||
}
|
||||
|
||||
private configurationByRoot: TernarySearchTree<any> = TernarySearchTree.forPaths<any>();
|
||||
private configurationByRoot: TernarySearchTree<string, any> = TernarySearchTree.forPaths<any>();
|
||||
|
||||
public reloadConfiguration<T>(): Promise<T> {
|
||||
return Promise.resolve(this.getValue());
|
||||
|
||||
@@ -13,6 +13,14 @@ export interface IMachineInfo {
|
||||
cpus?: string;
|
||||
memory: string;
|
||||
vmHint: string;
|
||||
linuxEnv?: ILinuxEnv;
|
||||
}
|
||||
|
||||
export interface ILinuxEnv {
|
||||
desktopSession?: string;
|
||||
xdgSessionDesktop?: string;
|
||||
xdgCurrentDesktop?: string;
|
||||
xdgSessionType?: string;
|
||||
}
|
||||
|
||||
export interface IDiagnosticInfo {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { parse, ParseError, getNodeType } from 'vs/base/common/json';
|
||||
import { listProcesses } from 'vs/base/node/ps';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { repeat, pad } from 'vs/base/common/strings';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { isWindows, isLinux } from 'vs/base/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ProcessItem } from 'vs/base/common/processes';
|
||||
import { IMainProcessInfo } from 'vs/platform/launch/common/launch';
|
||||
@@ -336,11 +336,19 @@ export class DiagnosticsService implements IDiagnosticsService {
|
||||
remoteData
|
||||
};
|
||||
|
||||
|
||||
if (!isWindows) {
|
||||
systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`;
|
||||
}
|
||||
|
||||
if (isLinux) {
|
||||
systemInfo.linuxEnv = {
|
||||
desktopSession: process.env.DESKTOP_SESSION,
|
||||
xdgSessionDesktop: process.env.XDG_SESSION_DESKTOP,
|
||||
xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP,
|
||||
xdgSessionType: process.env.XDG_SESSION_TYPE
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve(systemInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { ScanCodeBinding } from 'vs/base/common/scanCode';
|
||||
import { KeybindingParser } from 'vs/base/common/keybindingParser';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
@@ -207,7 +207,7 @@ export class Driver implements IDriver, IWindowDriverRegistry {
|
||||
export async function serve(
|
||||
windowServer: IPCServer,
|
||||
handle: string,
|
||||
environmentService: IEnvironmentService,
|
||||
environmentService: INativeEnvironmentService,
|
||||
instantiationService: IInstantiationService
|
||||
): Promise<IDisposable> {
|
||||
const verbose = environmentService.driverVerbose;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
|
||||
import { MessageBoxOptions, MessageBoxReturnValue, shell, OpenDevToolsOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogOptions, OpenDialogReturnValue, CrashReporterStartOptions, crashReporter, Menu, BrowserWindow, app } from 'electron';
|
||||
import { INativeOpenWindowOptions } from 'vs/platform/windows/node/window';
|
||||
import { INativeOpenWindowOptions, IOpenedWindow, OpenContext } from 'vs/platform/windows/node/window';
|
||||
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { IOpenedWindow, OpenContext, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
@@ -21,6 +21,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
|
||||
export interface IElectronMainService extends AddFirstParameterToFunctions<IElectronService, Promise<unknown> /* only methods, not events */, number | undefined /* window ID */> { }
|
||||
|
||||
@@ -34,7 +35,7 @@ export class ElectronMainService implements IElectronMainService {
|
||||
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
|
||||
@IDialogMainService private readonly dialogMainService: IDialogMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEnvironmentService private readonly environmentService: INativeEnvironmentService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, SaveDialogOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogReturnValue, CrashReporterStartOptions } from 'electron';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IWindowOpenable, IOpenEmptyWindowOptions, IOpenedWindow } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { INativeOpenWindowOptions } from 'vs/platform/windows/node/window';
|
||||
import { INativeOpenWindowOptions, IOpenedWindow } from 'vs/platform/windows/node/window';
|
||||
|
||||
export const IElectronService = createDecorator<IElectronService>('electronService');
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user