mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -29,7 +29,7 @@ export class DelayedDragHandler extends Disposable {
|
||||
}));
|
||||
|
||||
['dragleave', 'drop', 'dragend'].forEach(type => {
|
||||
this._register(addDisposableListener(container, type as 'dragleave' | 'drop' | 'dragend', () => {
|
||||
this._register(addDisposableListener(container, type, () => {
|
||||
this.clearDragTimeout();
|
||||
}));
|
||||
});
|
||||
|
||||
15
src/vs/base/browser/hash.ts
Normal file
15
src/vs/base/browser/hash.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function createSHA1(content: string): Thenable<string> {
|
||||
if (typeof require !== 'undefined') {
|
||||
const _crypto: typeof crypto = require.__$__nodeRequire('crypto');
|
||||
return Promise.resolve(_crypto['createHash']('sha1').update(content).digest('hex'));
|
||||
}
|
||||
return crypto.subtle.digest('SHA-1', new TextEncoder().encode(content)).then(buffer => {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#Converting_a_digest_to_a_hex_string
|
||||
return Array.prototype.map.call(new Uint8Array(buffer), (value: number) => `00${value.toString(16)}`.slice(-2)).join('');
|
||||
});
|
||||
}
|
||||
@@ -678,7 +678,7 @@ export class ActionBar extends Disposable implements IActionRunner {
|
||||
|
||||
focus(index?: number): void;
|
||||
focus(selectFirst?: boolean): void;
|
||||
focus(arg?: any): void {
|
||||
focus(arg?: number | boolean): void {
|
||||
let selectFirst: boolean = false;
|
||||
let index: number | undefined = undefined;
|
||||
if (arg === undefined) {
|
||||
|
||||
@@ -334,7 +334,7 @@ export class BreadcrumbsWidget {
|
||||
|
||||
private _onClick(event: IMouseEvent): void {
|
||||
for (let el: HTMLElement | null = event.target; el; el = el.parentElement) {
|
||||
let idx = this._nodes.indexOf(el as any);
|
||||
let idx = this._nodes.indexOf(el as HTMLDivElement);
|
||||
if (idx >= 0) {
|
||||
this._focus(idx, event);
|
||||
this._select(idx, event);
|
||||
|
||||
@@ -40,7 +40,7 @@ export class Button extends Disposable {
|
||||
private buttonForeground: Color | undefined;
|
||||
private buttonBorder: Color | undefined;
|
||||
|
||||
private _onDidClick = this._register(new Emitter<any>());
|
||||
private _onDidClick = this._register(new Emitter<Event>());
|
||||
get onDidClick(): BaseEvent<Event> { return this._onDidClick.event; }
|
||||
|
||||
private focusTracker: DOM.IFocusTracker;
|
||||
|
||||
@@ -120,7 +120,7 @@ export class ContextView extends Disposable {
|
||||
|
||||
setContainer(container: HTMLElement | null): void {
|
||||
if (this.container) {
|
||||
this.toDisposeOnSetContainer = dispose(this.toDisposeOnSetContainer);
|
||||
dispose(this.toDisposeOnSetContainer);
|
||||
this.container.removeChild(this.view);
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
.monaco-workbench .dialog-box {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
width: min-content;
|
||||
min-width: 500px;
|
||||
max-width: 90%;
|
||||
min-height: 75px;
|
||||
padding: 5px;
|
||||
}
|
||||
@@ -134,12 +136,13 @@
|
||||
overflow: hidden; /* buttons row should never overflow */
|
||||
}
|
||||
|
||||
.monaco-workbench .monaco-workbench .dialog-box > .dialog-buttons-row {
|
||||
.monaco-workbench .dialog-box > .dialog-buttons-row {
|
||||
display: flex;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/** Dialog: Buttons */
|
||||
.monaco-workbench .monaco-workbench .dialog-box > .dialog-buttons-row > .dialog-buttons {
|
||||
.monaco-workbench .dialog-box > .dialog-buttons-row > .dialog-buttons {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -272,12 +272,12 @@ export class DropdownMenuActionItem extends BaseActionItem {
|
||||
private contextMenuProvider: IContextMenuProvider;
|
||||
private actionItemProvider?: IActionItemProvider;
|
||||
private keybindings?: (action: IAction) => ResolvedKeybinding | undefined;
|
||||
private clazz: string;
|
||||
private clazz: string | undefined;
|
||||
private anchorAlignmentProvider: (() => AnchorAlignment) | undefined;
|
||||
|
||||
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string, anchorAlignmentProvider?: () => AnchorAlignment) {
|
||||
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) {
|
||||
super(null, action);
|
||||
|
||||
this.menuActionsOrProvider = menuActionsOrProvider;
|
||||
@@ -292,7 +292,9 @@ export class DropdownMenuActionItem extends BaseActionItem {
|
||||
render(container: HTMLElement): void {
|
||||
const labelRenderer: ILabelRenderer = (el: HTMLElement): IDisposable | null => {
|
||||
this.element = append(el, $('a.action-label.icon'));
|
||||
addClasses(this.element, this.clazz);
|
||||
if (this.clazz) {
|
||||
addClasses(this.element, this.clazz);
|
||||
}
|
||||
|
||||
this.element.tabIndex = 0;
|
||||
this.element.setAttribute('role', 'button');
|
||||
|
||||
@@ -457,7 +457,7 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
|
||||
return { children, box };
|
||||
|
||||
} else if (json.type === 'leaf') {
|
||||
const view = deserializer.fromJSON(json.data) as T;
|
||||
const view: T = deserializer.fromJSON(json.data);
|
||||
return { view, box };
|
||||
}
|
||||
|
||||
@@ -481,9 +481,9 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
|
||||
throw new Error('Invalid JSON: \'height\' property must be a number.');
|
||||
}
|
||||
|
||||
const orientation = json.orientation as Orientation;
|
||||
const width = json.width as number;
|
||||
const height = json.height as number;
|
||||
const orientation = json.orientation;
|
||||
const width = json.width;
|
||||
const height = json.height;
|
||||
const box: Box = { top: 0, left: 0, width, height };
|
||||
|
||||
const root = SerializableGrid.deserializeNode(json.root, orientation, box, deserializer) as GridBranchNode<T>;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { renderOcticons } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
|
||||
import { escape } from 'vs/base/common/strings';
|
||||
@@ -54,10 +53,9 @@ export class HighlightedLabel {
|
||||
this.render();
|
||||
}
|
||||
|
||||
private render() {
|
||||
dom.clearNode(this.domNode);
|
||||
private render(): void {
|
||||
|
||||
let htmlContent: string[] = [];
|
||||
let htmlContent = '';
|
||||
let pos = 0;
|
||||
|
||||
for (const highlight of this.highlights) {
|
||||
@@ -65,27 +63,27 @@ export class HighlightedLabel {
|
||||
continue;
|
||||
}
|
||||
if (pos < highlight.start) {
|
||||
htmlContent.push('<span>');
|
||||
htmlContent += '<span>';
|
||||
const substring = this.text.substring(pos, highlight.start);
|
||||
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
|
||||
htmlContent.push('</span>');
|
||||
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
|
||||
htmlContent += '</span>';
|
||||
pos = highlight.end;
|
||||
}
|
||||
htmlContent.push('<span class="highlight">');
|
||||
htmlContent += '<span class="highlight">';
|
||||
const substring = this.text.substring(highlight.start, highlight.end);
|
||||
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
|
||||
htmlContent.push('</span>');
|
||||
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
|
||||
htmlContent += '</span>';
|
||||
pos = highlight.end;
|
||||
}
|
||||
|
||||
if (pos < this.text.length) {
|
||||
htmlContent.push('<span>');
|
||||
htmlContent += '<span>';
|
||||
const substring = this.text.substring(pos);
|
||||
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
|
||||
htmlContent.push('</span>');
|
||||
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
|
||||
htmlContent += '</span>';
|
||||
}
|
||||
|
||||
this.domNode.innerHTML = htmlContent.join('');
|
||||
this.domNode.innerHTML = htmlContent;
|
||||
this.domNode.title = this.title;
|
||||
this.didEverRender = true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface KeybindingLabelOptions {
|
||||
export class KeybindingLabel {
|
||||
|
||||
private domNode: HTMLElement;
|
||||
private keybinding: ResolvedKeybinding | null | undefined;
|
||||
private keybinding: ResolvedKeybinding | undefined;
|
||||
private matches: Matches | undefined;
|
||||
private didEverRender: boolean;
|
||||
|
||||
@@ -47,7 +47,7 @@ export class KeybindingLabel {
|
||||
return this.domNode;
|
||||
}
|
||||
|
||||
set(keybinding: ResolvedKeybinding | null | undefined, matches?: Matches) {
|
||||
set(keybinding: ResolvedKeybinding | undefined, matches?: Matches) {
|
||||
if (this.didEverRender && this.keybinding === keybinding && KeybindingLabel.areSame(this.matches, matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export function consolidate(groups: IRangedGroup[]): IRangedGroup[] {
|
||||
* collection.
|
||||
*/
|
||||
function concat(...groups: IRangedGroup[][]): IRangedGroup[] {
|
||||
return consolidate(groups.reduce((r, g) => r.concat(g), [] as IRangedGroup[]));
|
||||
return consolidate(groups.reduce((r, g) => r.concat(g), []));
|
||||
}
|
||||
|
||||
export class RangeMap {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Color } from 'vs/base/common/color';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { removeClasses, addClass, hasClass, addClasses, removeClass, hide, show } from 'vs/base/browser/dom';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { isNumber } from 'vs/base/common/types';
|
||||
|
||||
const css_done = 'done';
|
||||
const css_active = 'active';
|
||||
@@ -146,7 +147,7 @@ export class ProgressBar extends Disposable {
|
||||
* Finds out if this progress bar is configured with total work
|
||||
*/
|
||||
hasTotal(): boolean {
|
||||
return !isNaN(this.totalWork as number);
|
||||
return isNumber(this.totalWork);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,10 +173,11 @@ export class ProgressBar extends Disposable {
|
||||
}
|
||||
|
||||
private doSetWorked(value: number): ProgressBar {
|
||||
assert.ok(!isNaN(this.totalWork as number), 'Total work not set');
|
||||
assert.ok(isNumber(this.totalWork), 'Total work not set');
|
||||
const totalWork = this.totalWork!;
|
||||
|
||||
this.workedVal = value;
|
||||
this.workedVal = Math.min(this.totalWork as number, this.workedVal);
|
||||
this.workedVal = Math.min(totalWork, this.workedVal);
|
||||
|
||||
if (hasClass(this.element, css_infinite)) {
|
||||
removeClass(this.element, css_infinite);
|
||||
@@ -193,7 +195,7 @@ export class ProgressBar extends Disposable {
|
||||
addClass(this.element, css_discrete);
|
||||
}
|
||||
|
||||
this.bit.style.width = 100 * (this.workedVal / (this.totalWork as number)) + '%';
|
||||
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -818,18 +818,32 @@ class Trait<T> {
|
||||
return;
|
||||
}
|
||||
|
||||
const identityProvider = this.identityProvider;
|
||||
const nodesByIdentity = new Map<string, ITreeNode<T, any>>();
|
||||
this.nodes.forEach(node => nodesByIdentity.set(identityProvider.getId(node.element).toString(), node));
|
||||
const deletedNodesIdSet = new Set<string>();
|
||||
const deletedNodesVisitor = (node: ITreeNode<T, any>) => deletedNodesIdSet.add(this.identityProvider!.getId(node.element).toString());
|
||||
deletedNodes.forEach(node => dfs(node, deletedNodesVisitor));
|
||||
|
||||
const toDeleteByIdentity = new Map<string, ITreeNode<T, any>>();
|
||||
const toRemoveSetter = (node: ITreeNode<T, any>) => toDeleteByIdentity.set(identityProvider.getId(node.element).toString(), node);
|
||||
const toRemoveDeleter = (node: { element: T; }) => toDeleteByIdentity.delete(identityProvider.getId(node.element).toString());
|
||||
deletedNodes.forEach(node => dfs(node, toRemoveSetter));
|
||||
insertedNodes.forEach(node => dfs(node, toRemoveDeleter));
|
||||
const insertedNodesMap = new Map<string, ITreeNode<T, any>>();
|
||||
const insertedNodesVisitor = (node: ITreeNode<T, any>) => insertedNodesMap.set(this.identityProvider!.getId(node.element).toString(), node);
|
||||
insertedNodes.forEach(node => dfs(node, insertedNodesVisitor));
|
||||
|
||||
toDeleteByIdentity.forEach((_, id) => nodesByIdentity.delete(id));
|
||||
this.set(values(nodesByIdentity));
|
||||
const nodes: ITreeNode<T, any>[] = [];
|
||||
|
||||
for (const node of this.nodes) {
|
||||
const id = this.identityProvider.getId(node.element).toString();
|
||||
const wasDeleted = deletedNodesIdSet.has(id);
|
||||
|
||||
if (!wasDeleted) {
|
||||
nodes.push(node);
|
||||
} else {
|
||||
const insertedNode = insertedNodesMap.get(id);
|
||||
|
||||
if (insertedNode) {
|
||||
nodes.push(insertedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.set(nodes);
|
||||
}
|
||||
|
||||
private createNodeSet(): Set<ITreeNode<T, any>> {
|
||||
|
||||
Reference in New Issue
Block a user