mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export interface ITelemetryData {
|
||||
from?: string;
|
||||
|
||||
@@ -53,7 +53,7 @@ export function binarySearch<T>(array: T[], key: T, comparator: (op1: T, op2: T)
|
||||
* are located before all elements where p(x) is true.
|
||||
* @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
|
||||
*/
|
||||
export function findFirst<T>(array: T[], p: (x: T) => boolean): number {
|
||||
export function findFirstInSorted<T>(array: T[], p: (x: T) => boolean): number {
|
||||
let low = 0, high = array.length;
|
||||
if (high === 0) {
|
||||
return 0; // no children
|
||||
@@ -267,7 +267,7 @@ function topStep<T>(array: T[], compare: (a: T, b: T) => number, result: T[], i:
|
||||
const element = array[i];
|
||||
if (compare(element, result[n - 1]) < 0) {
|
||||
result.pop();
|
||||
const j = findFirst(result, e => compare(element, e) < 0);
|
||||
const j = findFirstInSorted(result, e => compare(element, e) < 0);
|
||||
result.splice(j, 0, element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as errors from 'vs/base/common/errors';
|
||||
import { Promise, TPromise, ValueCallback, ErrorCallback, ProgressCallback } from 'vs/base/common/winjs.base';
|
||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
export function isThenable<T>(obj: any): obj is Thenable<T> {
|
||||
@@ -29,10 +29,23 @@ export function asWinJsPromise<T>(callback: (token: CancellationToken) => T | TP
|
||||
return new TPromise<T>((resolve, reject, progress) => {
|
||||
let item = callback(source.token);
|
||||
if (item instanceof TPromise) {
|
||||
item.then(resolve, reject, progress);
|
||||
item.then(result => {
|
||||
source.dispose();
|
||||
resolve(result);
|
||||
}, err => {
|
||||
source.dispose();
|
||||
reject(err);
|
||||
}, progress);
|
||||
} else if (isThenable<T>(item)) {
|
||||
item.then(resolve, reject);
|
||||
item.then(result => {
|
||||
source.dispose();
|
||||
resolve(result);
|
||||
}, err => {
|
||||
source.dispose();
|
||||
reject(err);
|
||||
});
|
||||
} else {
|
||||
source.dispose();
|
||||
resolve(item);
|
||||
}
|
||||
}, () => {
|
||||
@@ -320,6 +333,10 @@ export function timeout(n: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, n));
|
||||
}
|
||||
|
||||
function isWinJSPromise(candidate: any): candidate is TPromise {
|
||||
return TPromise.is(candidate) && typeof (<TPromise>candidate).done === 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new promise that joins the provided promise. Upon completion of
|
||||
* the provided promise the provided function will always be called. This
|
||||
@@ -327,28 +344,37 @@ export function timeout(n: number): Promise<void> {
|
||||
* @param promise a promise
|
||||
* @param f a function that will be call in the success and error case.
|
||||
*/
|
||||
export function always<T>(promise: TPromise<T>, f: Function): TPromise<T> {
|
||||
return new TPromise<T>((c, e, p) => {
|
||||
promise.done((result) => {
|
||||
try {
|
||||
f(result);
|
||||
} catch (e1) {
|
||||
errors.onUnexpectedError(e1);
|
||||
}
|
||||
c(result);
|
||||
}, (err) => {
|
||||
try {
|
||||
f(err);
|
||||
} catch (e1) {
|
||||
errors.onUnexpectedError(e1);
|
||||
}
|
||||
e(err);
|
||||
}, (progress) => {
|
||||
p(progress);
|
||||
export function always<T>(thenable: TPromise<T>, f: Function): TPromise<T>;
|
||||
export function always<T>(promise: Thenable<T>, f: Function): Thenable<T>;
|
||||
export function always<T>(winjsPromiseOrThenable: Thenable<T> | TPromise<T>, f: Function): TPromise<T> | Thenable<T> {
|
||||
if (isWinJSPromise(winjsPromiseOrThenable)) {
|
||||
return new TPromise<T>((c, e, p) => {
|
||||
winjsPromiseOrThenable.done((result) => {
|
||||
try {
|
||||
f(result);
|
||||
} catch (e1) {
|
||||
errors.onUnexpectedError(e1);
|
||||
}
|
||||
c(result);
|
||||
}, (err) => {
|
||||
try {
|
||||
f(err);
|
||||
} catch (e1) {
|
||||
errors.onUnexpectedError(e1);
|
||||
}
|
||||
e(err);
|
||||
}, (progress) => {
|
||||
p(progress);
|
||||
});
|
||||
}, () => {
|
||||
winjsPromiseOrThenable.cancel();
|
||||
});
|
||||
}, () => {
|
||||
promise.cancel();
|
||||
});
|
||||
|
||||
} else {
|
||||
// simple
|
||||
winjsPromiseOrThenable.then(_ => f(), _ => f());
|
||||
return winjsPromiseOrThenable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,7 +450,7 @@ export class Limiter<T> {
|
||||
private runningPromises: number;
|
||||
private maxDegreeOfParalellism: number;
|
||||
private outstandingPromises: ILimitedTaskFactory[];
|
||||
private _onFinished: Emitter<void>;
|
||||
private readonly _onFinished: Emitter<void>;
|
||||
|
||||
constructor(maxDegreeOfParalellism: number) {
|
||||
this.maxDegreeOfParalellism = maxDegreeOfParalellism;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export interface CancellationToken {
|
||||
@@ -45,7 +45,7 @@ class MutableToken implements CancellationToken {
|
||||
this._isCancelled = true;
|
||||
if (this._emitter) {
|
||||
this._emitter.fire(undefined);
|
||||
this._emitter = undefined;
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,13 @@ class MutableToken implements CancellationToken {
|
||||
}
|
||||
return this._emitter.event;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._emitter) {
|
||||
this._emitter.dispose();
|
||||
this._emitter = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class CancellationTokenSource {
|
||||
@@ -92,6 +99,13 @@ export class CancellationTokenSource {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.cancel();
|
||||
if (!this._token) {
|
||||
// ensure to initialize with an empty token if we had none
|
||||
this._token = CancellationToken.None;
|
||||
|
||||
} else if (this._token instanceof MutableToken) {
|
||||
// actually dispose
|
||||
this._token.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ export function memoize(target: any, key: string, descriptor: any) {
|
||||
if (typeof descriptor.value === 'function') {
|
||||
fnKey = 'value';
|
||||
fn = descriptor.value;
|
||||
|
||||
if (fn.length !== 0) {
|
||||
console.warn('Memoize should only be used in functions with zero parameters');
|
||||
}
|
||||
} else if (typeof descriptor.get === 'function') {
|
||||
fnKey = 'get';
|
||||
fn = descriptor.get;
|
||||
@@ -58,13 +62,27 @@ export function memoize(target: any, key: string, descriptor: any) {
|
||||
};
|
||||
}
|
||||
|
||||
export function debounce(delay: number): Function {
|
||||
export interface IDebouceReducer<T> {
|
||||
(previousValue: T, ...args: any[]): T;
|
||||
}
|
||||
|
||||
export function debounce<T>(delay: number, reducer?: IDebouceReducer<T>, initialValueProvider?: () => T): Function {
|
||||
return createDecorator((fn, key) => {
|
||||
const timerKey = `$debounce$${key}`;
|
||||
let result = initialValueProvider ? initialValueProvider() : void 0;
|
||||
|
||||
return function (this: any, ...args: any[]) {
|
||||
clearTimeout(this[timerKey]);
|
||||
this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
|
||||
|
||||
if (reducer) {
|
||||
result = reducer(result, ...args);
|
||||
args = [result];
|
||||
}
|
||||
|
||||
this[timerKey] = setTimeout(() => {
|
||||
fn.apply(this, args);
|
||||
result = initialValueProvider ? initialValueProvider() : void 0;
|
||||
}, delay);
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import types = require('vs/base/common/types');
|
||||
import arrays = require('vs/base/common/arrays');
|
||||
import * as nls from 'vs/nls';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
|
||||
function exceptionToErrorMessage(exception: any, verbose: boolean): string {
|
||||
if (exception.message) {
|
||||
|
||||
@@ -14,17 +14,15 @@ import { LinkedList } from 'vs/base/common/linkedList';
|
||||
* To an event a function with one or zero parameters
|
||||
* can be subscribed. The event is the subscriber function itself.
|
||||
*/
|
||||
interface Event<T> {
|
||||
export interface Event<T> {
|
||||
(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
|
||||
}
|
||||
|
||||
namespace Event {
|
||||
export namespace Event {
|
||||
const _disposable = { dispose() { } };
|
||||
export const None: Event<any> = function () { return _disposable; };
|
||||
}
|
||||
|
||||
export default Event;
|
||||
|
||||
type Listener = [Function, any] | Function;
|
||||
|
||||
export interface EmitterOptions {
|
||||
@@ -163,7 +161,7 @@ export class Emitter<T> {
|
||||
|
||||
export class EventMultiplexer<T> implements IDisposable {
|
||||
|
||||
private emitter: Emitter<T>;
|
||||
private readonly emitter: Emitter<T>;
|
||||
private hasListeners = false;
|
||||
private events: { event: Event<T>; listener: IDisposable; }[] = [];
|
||||
|
||||
@@ -281,7 +279,7 @@ export function debounceEvent<I, O>(event: Event<I>, merger: (last: O, event: I)
|
||||
|
||||
let subscription: IDisposable;
|
||||
let output: O = undefined;
|
||||
let handle: number = undefined;
|
||||
let handle: any = undefined;
|
||||
let numDebouncedCalls = 0;
|
||||
|
||||
const emitter = new Emitter<O>({
|
||||
@@ -367,6 +365,7 @@ export interface IChainableEvent<T> {
|
||||
map<O>(fn: (i: T) => O): IChainableEvent<O>;
|
||||
forEach(fn: (i: T) => void): IChainableEvent<T>;
|
||||
filter(fn: (e: T) => boolean): IChainableEvent<T>;
|
||||
latch(): IChainableEvent<T>;
|
||||
on(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
|
||||
}
|
||||
|
||||
@@ -400,6 +399,10 @@ class ChainableEvent<T> implements IChainableEvent<T> {
|
||||
return new ChainableEvent(filterEvent(this._event, fn));
|
||||
}
|
||||
|
||||
latch(): IChainableEvent<T> {
|
||||
return new ChainableEvent(latch(this._event));
|
||||
}
|
||||
|
||||
on(listener: (e: T) => any, thisArgs: any, disposables: IDisposable[]) {
|
||||
return this._event(listener, thisArgs, disposables);
|
||||
}
|
||||
@@ -536,3 +539,15 @@ export function fromNodeEventEmitter<T>(emitter: NodeEventEmitter, eventName: st
|
||||
|
||||
return result.event;
|
||||
}
|
||||
|
||||
export function latch<T>(event: Event<T>): Event<T> {
|
||||
let firstCall = true;
|
||||
let cache: T;
|
||||
|
||||
return filterEvent(event, value => {
|
||||
let shouldEmit = firstCall || value !== cache;
|
||||
firstCall = false;
|
||||
cache = value;
|
||||
return shouldEmit;
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import strings = require('vs/base/common/strings');
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { LRUCache } from 'vs/base/common/map';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
|
||||
@@ -50,7 +50,7 @@ function _matchesPrefix(ignoreCase: boolean, word: string, wordToMatchAgainst: s
|
||||
|
||||
let matches: boolean;
|
||||
if (ignoreCase) {
|
||||
matches = strings.beginsWithIgnoreCase(wordToMatchAgainst, word);
|
||||
matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
|
||||
} else {
|
||||
matches = wordToMatchAgainst.indexOf(word) === 0;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import arrays = require('vs/base/common/arrays');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import paths = require('vs/base/common/paths');
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import { LRUCache } from 'vs/base/common/map';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
@@ -65,6 +65,11 @@ export class HistoryNavigator<T> implements INavigator<T> {
|
||||
return this._navigator.last();
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this._initialize([]);
|
||||
this._onChange();
|
||||
}
|
||||
|
||||
private _onChange() {
|
||||
this._reduceToLimit();
|
||||
this._navigator = new ArrayNavigator(this._elements);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import Json = require('./json');
|
||||
import * as Json from './json';
|
||||
|
||||
export interface FormattingOptions {
|
||||
/**
|
||||
|
||||
@@ -54,10 +54,10 @@ export const UILabelProvider = new ModifierLabelProvider(
|
||||
separator: '',
|
||||
},
|
||||
{
|
||||
ctrlKey: nls.localize('ctrlKey', "Ctrl"),
|
||||
shiftKey: nls.localize('shiftKey', "Shift"),
|
||||
altKey: nls.localize('altKey', "Alt"),
|
||||
metaKey: nls.localize('windowsKey', "Windows"),
|
||||
ctrlKey: nls.localize({ key: 'ctrlKey', comment: ['This is the short form for the Control key on the keyboard'] }, "Ctrl"),
|
||||
shiftKey: nls.localize({ key: 'shiftKey', comment: ['This is the short form for the Shift key on the keyboard'] }, "Shift"),
|
||||
altKey: nls.localize({ key: 'altKey', comment: ['This is the short form for the Alt key on the keyboard'] }, "Alt"),
|
||||
metaKey: nls.localize({ key: 'windowsKey', comment: ['This is the short form for the Windows key on the keyboard'] }, "Windows"),
|
||||
separator: '+',
|
||||
}
|
||||
);
|
||||
@@ -67,17 +67,17 @@ export const UILabelProvider = new ModifierLabelProvider(
|
||||
*/
|
||||
export const AriaLabelProvider = new ModifierLabelProvider(
|
||||
{
|
||||
ctrlKey: nls.localize('ctrlKey.long', "Control"),
|
||||
shiftKey: nls.localize('shiftKey.long', "Shift"),
|
||||
altKey: nls.localize('altKey.long', "Alt"),
|
||||
metaKey: nls.localize('cmdKey.long', "Command"),
|
||||
ctrlKey: nls.localize({ key: 'ctrlKey.long', comment: ['This is the long form for the Control key on the keyboard'] }, "Control"),
|
||||
shiftKey: nls.localize({ key: 'shiftKey.long', comment: ['This is the long form for the Shift key on the keyboard'] }, "Shift"),
|
||||
altKey: nls.localize({ key: 'altKey.long', comment: ['This is the long form for the Alt key on the keyboard'] }, "Alt"),
|
||||
metaKey: nls.localize({ key: 'cmdKey.long', comment: ['This is the long form for the Command key on the keyboard'] }, "Command"),
|
||||
separator: '+',
|
||||
},
|
||||
{
|
||||
ctrlKey: nls.localize('ctrlKey.long', "Control"),
|
||||
shiftKey: nls.localize('shiftKey.long', "Shift"),
|
||||
altKey: nls.localize('altKey.long', "Alt"),
|
||||
metaKey: nls.localize('windowsKey.long', "Windows"),
|
||||
ctrlKey: nls.localize({ key: 'ctrlKey.long', comment: ['This is the long form for the Control key on the keyboard'] }, "Control"),
|
||||
shiftKey: nls.localize({ key: 'shiftKey.long', comment: ['This is the long form for the Shift key on the keyboard'] }, "Shift"),
|
||||
altKey: nls.localize({ key: 'altKey.long', comment: ['This is the long form for the Alt key on the keyboard'] }, "Alt"),
|
||||
metaKey: nls.localize({ key: 'windowsKey.long', comment: ['This is the long form for the Windows key on the keyboard'] }, "Windows"),
|
||||
separator: '+',
|
||||
}
|
||||
);
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import platform = require('vs/base/common/platform');
|
||||
import { nativeSep, normalize, isEqualOrParent, isEqual, basename as pathsBasename, join } from 'vs/base/common/paths';
|
||||
import { endsWith, ltrim } from 'vs/base/common/strings';
|
||||
import { nativeSep, normalize, basename as pathsBasename, join, sep } from 'vs/base/common/paths';
|
||||
import { endsWith, ltrim, equalsIgnoreCase, startsWithIgnoreCase, rtrim, startsWith } from 'vs/base/common/strings';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { isLinux, isWindows, isMacintosh } from 'vs/base/common/platform';
|
||||
|
||||
export interface IWorkspaceFolderProvider {
|
||||
getWorkspaceFolder(resource: URI): { uri: URI };
|
||||
@@ -30,6 +30,7 @@ export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFo
|
||||
resource = URI.file(resource);
|
||||
}
|
||||
|
||||
// return early if the resource is neither file:// nor untitled://
|
||||
if (resource.scheme !== Schemas.file && resource.scheme !== Schemas.untitled) {
|
||||
return resource.with({ query: null, fragment: null }).toString(true);
|
||||
}
|
||||
@@ -40,7 +41,7 @@ export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFo
|
||||
const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
|
||||
|
||||
let pathLabel: string;
|
||||
if (isEqual(baseResource.uri.fsPath, resource.fsPath, !platform.isLinux /* ignorecase */)) {
|
||||
if (isLinux ? baseResource.uri.fsPath === resource.fsPath : equalsIgnoreCase(baseResource.uri.fsPath, resource.fsPath)) {
|
||||
pathLabel = ''; // no label if pathes are identical
|
||||
} else {
|
||||
pathLabel = normalize(ltrim(resource.fsPath.substr(baseResource.uri.fsPath.length), nativeSep), true);
|
||||
@@ -61,7 +62,7 @@ export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFo
|
||||
|
||||
// normalize and tildify (macOS, Linux only)
|
||||
let res = normalize(resource.fsPath, true);
|
||||
if (!platform.isWindows && userHomeProvider) {
|
||||
if (!isWindows && userHomeProvider) {
|
||||
res = tildify(res, userHomeProvider.userHome);
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ export function getBaseLabel(resource: URI | string): string {
|
||||
}
|
||||
|
||||
function hasDriveLetter(path: string): boolean {
|
||||
return platform.isWindows && path && path[1] === ':';
|
||||
return isWindows && path && path[1] === ':';
|
||||
}
|
||||
|
||||
export function normalizeDriveLetter(path: string): string {
|
||||
@@ -99,9 +100,22 @@ export function normalizeDriveLetter(path: string): string {
|
||||
return path;
|
||||
}
|
||||
|
||||
let normalizedUserHomeCached: { original: string; normalized: string } = Object.create(null);
|
||||
export function tildify(path: string, userHome: string): string {
|
||||
if (path && (platform.isMacintosh || platform.isLinux) && isEqualOrParent(path, userHome, !platform.isLinux /* ignorecase */)) {
|
||||
path = `~${path.substr(userHome.length)}`;
|
||||
if (isWindows || !path || !userHome) {
|
||||
return path; // unsupported
|
||||
}
|
||||
|
||||
// Keep a normalized user home path as cache to prevent accumulated string creation
|
||||
let normalizedUserHome = normalizedUserHomeCached.original === userHome ? normalizedUserHomeCached.normalized : void 0;
|
||||
if (!normalizedUserHome) {
|
||||
normalizedUserHome = `${rtrim(userHome, sep)}${sep}`;
|
||||
normalizedUserHomeCached = { original: userHome, normalized: normalizedUserHome };
|
||||
}
|
||||
|
||||
// Linux: case sensitive, macOS: case insensitive
|
||||
if (isLinux ? startsWith(path, normalizedUserHome) : startsWithIgnoreCase(path, normalizedUserHome)) {
|
||||
path = `~/${path.substr(normalizedUserHome.length)}`;
|
||||
}
|
||||
|
||||
return path;
|
||||
@@ -325,7 +339,7 @@ export function template(template: string, values: { [key: string]: string | ISe
|
||||
const left = segments[index - 1];
|
||||
const right = segments[index + 1];
|
||||
|
||||
return [left, right].every(segment => segment && segment.type === Type.VARIABLE && segment.value.length > 0);
|
||||
return [left, right].every(segment => segment && (segment.type === Type.VARIABLE || segment.type === Type.TEXT) && segment.value.length > 0);
|
||||
}
|
||||
|
||||
// accept any TEXT and VARIABLE
|
||||
@@ -340,7 +354,7 @@ export function template(template: string, values: { [key: string]: string | ISe
|
||||
* - macOS: Unsupported (replace && with empty string)
|
||||
*/
|
||||
export function mnemonicMenuLabel(label: string, forceDisableMnemonics?: boolean): string {
|
||||
if (platform.isMacintosh || forceDisableMnemonics) {
|
||||
if (isMacintosh || forceDisableMnemonics) {
|
||||
return label.replace(/\(&&\w\)|&&/g, '');
|
||||
}
|
||||
|
||||
@@ -354,11 +368,11 @@ export function mnemonicMenuLabel(label: string, forceDisableMnemonics?: boolean
|
||||
* - macOS: Unsupported (replace && with empty string)
|
||||
*/
|
||||
export function mnemonicButtonLabel(label: string): string {
|
||||
if (platform.isMacintosh) {
|
||||
if (isMacintosh) {
|
||||
return label.replace(/\(&&\w\)|&&/g, '');
|
||||
}
|
||||
|
||||
return label.replace(/&&/g, platform.isWindows ? '&' : '_');
|
||||
return label.replace(/&&/g, isWindows ? '&' : '_');
|
||||
}
|
||||
|
||||
export function unmnemonicLabel(label: string): string {
|
||||
|
||||
@@ -368,10 +368,12 @@ export class TernarySearchTree<E> {
|
||||
|
||||
export class ResourceMap<T> {
|
||||
|
||||
protected map: Map<string, T>;
|
||||
protected readonly map: Map<string, T>;
|
||||
protected readonly ignoreCase?: boolean;
|
||||
|
||||
constructor(private ignoreCase?: boolean) {
|
||||
constructor() {
|
||||
this.map = new Map<string, T>();
|
||||
this.ignoreCase = false; // in the future this should be an uri-comparator
|
||||
}
|
||||
|
||||
public set(resource: URI, value: T): void {
|
||||
@@ -414,18 +416,10 @@ export class ResourceMap<T> {
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
export class StrictResourceMap<T> extends ResourceMap<T> {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public keys(): URI[] {
|
||||
return keys(this.map).map(key => URI.parse(key));
|
||||
return keys(this.map).map(URI.parse);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We should fold BoundedMap and LinkedMap. See https://github.com/Microsoft/vscode/issues/28496
|
||||
@@ -743,6 +737,24 @@ export class LinkedMap<K, V> {
|
||||
this._tail = item;
|
||||
}
|
||||
}
|
||||
|
||||
public toJSON(): [K, V][] {
|
||||
const data: [K, V][] = [];
|
||||
|
||||
this.forEach((value, key) => {
|
||||
data.push([key, value]);
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public fromJSON(data: [K, V][]): void {
|
||||
this.clear();
|
||||
|
||||
for (const [key, value] of data) {
|
||||
this.set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class LRUCache<K, V> extends LinkedMap<K, V> {
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
[{
|
||||
"name": "chjj-marked",
|
||||
"repositoryURL": "https://github.com/npmcomponent/chjj-marked",
|
||||
"version": "0.3.12",
|
||||
"version": "0.3.18",
|
||||
"license": "MIT"
|
||||
}]
|
||||
|
||||
2
src/vs/base/common/marked/marked.d.ts
vendored
2
src/vs/base/common/marked/marked.d.ts
vendored
@@ -73,7 +73,7 @@ export interface MarkedStatic {
|
||||
|
||||
export interface Renderer {
|
||||
prototype: MarkedRenderer;
|
||||
new (): MarkedRenderer;
|
||||
new(): MarkedRenderer;
|
||||
}
|
||||
|
||||
export interface MarkedRenderer {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ export function parse(text: string): any {
|
||||
return data;
|
||||
}
|
||||
|
||||
interface MarshalledObject {
|
||||
export interface MarshalledObject {
|
||||
$mid: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import paths = require('vs/base/common/paths');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { match } from 'vs/base/common/glob';
|
||||
|
||||
export const MIME_TEXT = 'text/plain';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { beginsWithIgnoreCase, equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { startsWithIgnoreCase, equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
|
||||
/**
|
||||
@@ -27,6 +27,8 @@ export function dirname(path: string): string {
|
||||
return '.';
|
||||
} else if (~idx === 0) {
|
||||
return path[0];
|
||||
} else if (~idx === path.length - 1) {
|
||||
return dirname(path.substring(0, path.length - 1));
|
||||
} else {
|
||||
let res = path.substring(0, ~idx);
|
||||
if (isWindows && res[res.length - 1] === ':') {
|
||||
@@ -340,7 +342,7 @@ export function isEqualOrParent(path: string, candidate: string, ignoreCase?: bo
|
||||
}
|
||||
|
||||
if (ignoreCase) {
|
||||
const beginsWith = beginsWithIgnoreCase(path, candidate);
|
||||
const beginsWith = startsWithIgnoreCase(path, candidate);
|
||||
if (!beginsWith) {
|
||||
return false;
|
||||
}
|
||||
@@ -395,4 +397,4 @@ export function isAbsolute_win32(path: string): boolean {
|
||||
|
||||
export function isAbsolute_posix(path: string): boolean {
|
||||
return path && path.charCodeAt(0) === CharCode.Slash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ declare let self: any;
|
||||
export const LANGUAGE_DEFAULT = 'en';
|
||||
|
||||
// OS detection
|
||||
if (typeof process === 'object' && typeof process.nextTick === 'function') {
|
||||
if (typeof process === 'object' && typeof process.nextTick === 'function' && typeof process.platform === 'string') {
|
||||
_isWindows = (process.platform === 'win32');
|
||||
_isMacintosh = (process.platform === 'darwin');
|
||||
_isLinux = (process.platform === 'linux');
|
||||
@@ -120,6 +120,20 @@ export const translationsConfigFile = _translationsConfigFile;
|
||||
const _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {} as any);
|
||||
export const globals: any = _globals;
|
||||
|
||||
let _setImmediate: (callback: (...args: any[]) => void) => number = null;
|
||||
export function setImmediate(callback: (...args: any[]) => void): number {
|
||||
if (_setImmediate === null) {
|
||||
if (globals.setImmediate) {
|
||||
_setImmediate = globals.setImmediate.bind(globals);
|
||||
} else if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
|
||||
_setImmediate = process.nextTick.bind(process);
|
||||
} else {
|
||||
_setImmediate = globals.setTimeout.bind(globals);
|
||||
}
|
||||
}
|
||||
return _setImmediate(callback);
|
||||
}
|
||||
|
||||
export const enum OperatingSystem {
|
||||
Windows = 1,
|
||||
Macintosh = 2,
|
||||
|
||||
@@ -9,12 +9,16 @@ import uri from 'vs/base/common/uri';
|
||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
|
||||
export function basenameOrAuthority(resource: uri): string {
|
||||
return paths.basename(resource.fsPath) || resource.authority;
|
||||
return paths.basename(resource.path) || resource.authority;
|
||||
}
|
||||
|
||||
export function isEqualOrParent(resource: uri, candidate: uri, ignoreCase?: boolean): boolean {
|
||||
if (resource.scheme === candidate.scheme && resource.authority === candidate.authority) {
|
||||
return paths.isEqualOrParent(resource.fsPath, candidate.fsPath, ignoreCase);
|
||||
if (resource.scheme === 'file') {
|
||||
return paths.isEqualOrParent(resource.fsPath, candidate.fsPath, ignoreCase);
|
||||
}
|
||||
|
||||
return paths.isEqualOrParent(resource.path, candidate.path, ignoreCase);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -66,4 +70,4 @@ export function distinctParents<T>(items: T[], resourceAccessor: (item: T) => ur
|
||||
}
|
||||
|
||||
return distinctParents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export enum ScrollbarVisibility {
|
||||
Auto = 1,
|
||||
@@ -186,7 +186,7 @@ export class Scrollable extends Disposable {
|
||||
private _smoothScrolling: SmoothScrollingOperation;
|
||||
|
||||
private _onScroll = this._register(new Emitter<ScrollEvent>());
|
||||
public onScroll: Event<ScrollEvent> = this._onScroll.event;
|
||||
public readonly onScroll: Event<ScrollEvent> = this._onScroll.event;
|
||||
|
||||
constructor(smoothScrollDuration: number, scheduleAtNextAnimationFrame: (callback: () => void) => IDisposable) {
|
||||
super();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export interface ISplice<T> {
|
||||
readonly start: number;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import * as nls from 'vs/nls';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
|
||||
enum Severity {
|
||||
Ignore = 0,
|
||||
@@ -46,17 +46,8 @@ namespace Severity {
|
||||
if (strings.equalsIgnoreCase(_info, value)) {
|
||||
return Severity.Info;
|
||||
}
|
||||
|
||||
return Severity.Ignore;
|
||||
}
|
||||
|
||||
export function toString(value: Severity): string {
|
||||
return _displayStrings[value] || strings.empty;
|
||||
}
|
||||
|
||||
export function compare(a: Severity, b: Severity): number {
|
||||
return b - a;
|
||||
}
|
||||
}
|
||||
|
||||
export default Severity;
|
||||
export default Severity;
|
||||
|
||||
@@ -159,6 +159,10 @@ export function startsWith(haystack: string, needle: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (haystack === needle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < needle.length; i++) {
|
||||
if (haystack[i] !== needle[i]) {
|
||||
return false;
|
||||
@@ -427,7 +431,7 @@ function doEqualsIgnoreCase(a: string, b: string, stopAt = a.length): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function beginsWithIgnoreCase(str: string, candidate: string): boolean {
|
||||
export function startsWithIgnoreCase(str: string, candidate: string): boolean {
|
||||
const candidateLength = candidate.length;
|
||||
if (candidate.length > str.length) {
|
||||
return false;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Promise as WinJSPromise } from './winjs.base';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
/**
|
||||
* A polyfill for the native promises. The implementation is based on
|
||||
@@ -53,13 +54,13 @@ export class PolyfillPromise<T = any> implements Promise<T> {
|
||||
if (!initializing) {
|
||||
resolve(value);
|
||||
} else {
|
||||
setImmediate(resolve, value);
|
||||
platform.setImmediate(() => resolve(value));
|
||||
}
|
||||
}, function (err) {
|
||||
if (!initializing) {
|
||||
reject(err);
|
||||
} else {
|
||||
setImmediate(reject, err);
|
||||
platform.setImmediate(() => reject(err));
|
||||
}
|
||||
});
|
||||
initializing = false;
|
||||
@@ -74,14 +75,14 @@ export class PolyfillPromise<T = any> implements Promise<T> {
|
||||
if (!sync) {
|
||||
onFulfilled(value);
|
||||
} else {
|
||||
setImmediate(onFulfilled, value);
|
||||
platform.setImmediate(() => onFulfilled(value));
|
||||
}
|
||||
},
|
||||
onRejected && function (err) {
|
||||
if (!sync) {
|
||||
onFulfilled(err);
|
||||
onRejected(err);
|
||||
} else {
|
||||
setImmediate(onFulfilled, err);
|
||||
platform.setImmediate(() => onRejected(err));
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
@@ -116,7 +116,7 @@ class SimpleWorkerProtocol {
|
||||
} catch (e) {
|
||||
// nothing
|
||||
}
|
||||
if (!message.vsWorker) {
|
||||
if (!message || !message.vsWorker) {
|
||||
return;
|
||||
}
|
||||
if (this._workerId !== -1 && message.vsWorker !== this._workerId) {
|
||||
@@ -224,10 +224,9 @@ export class SimpleWorkerClient<T> extends Disposable {
|
||||
|
||||
// Gather loader configuration
|
||||
let loaderConfiguration: any = null;
|
||||
let globalRequire = (<any>self).require;
|
||||
if (typeof globalRequire.getConfig === 'function') {
|
||||
if (typeof (<any>self).require !== 'undefined' && typeof (<any>self).require.getConfig === 'function') {
|
||||
// Get the configuration from the Monaco AMD Loader
|
||||
loaderConfiguration = globalRequire.getConfig();
|
||||
loaderConfiguration = (<any>self).require.getConfig();
|
||||
} else if (typeof (<any>self).requirejs !== 'undefined') {
|
||||
// Get the configuration from requirejs
|
||||
loaderConfiguration = (<any>self).requirejs.s.contexts._.config;
|
||||
@@ -298,10 +297,11 @@ export interface IRequestHandler {
|
||||
*/
|
||||
export class SimpleWorkerServer {
|
||||
|
||||
private _protocol: SimpleWorkerProtocol;
|
||||
private _requestHandler: IRequestHandler;
|
||||
private _protocol: SimpleWorkerProtocol;
|
||||
|
||||
constructor(postSerializedMessage: (msg: string) => void) {
|
||||
constructor(postSerializedMessage: (msg: string) => void, requestHandler: IRequestHandler) {
|
||||
this._requestHandler = requestHandler;
|
||||
this._protocol = new SimpleWorkerProtocol({
|
||||
sendMessage: (msg: string): void => {
|
||||
postSerializedMessage(msg);
|
||||
@@ -333,6 +333,17 @@ export class SimpleWorkerServer {
|
||||
private initialize(workerId: number, moduleId: string, loaderConfig: any): TPromise<any> {
|
||||
this._protocol.setWorkerId(workerId);
|
||||
|
||||
if (this._requestHandler) {
|
||||
// static request handler
|
||||
let methods: string[] = [];
|
||||
for (let prop in this._requestHandler) {
|
||||
if (typeof this._requestHandler[prop] === 'function') {
|
||||
methods.push(prop);
|
||||
}
|
||||
}
|
||||
return TPromise.as(methods);
|
||||
}
|
||||
|
||||
if (loaderConfig) {
|
||||
// Remove 'baseUrl', handling it is beyond scope for now
|
||||
if (typeof loaderConfig.baseUrl !== 'undefined') {
|
||||
@@ -379,5 +390,5 @@ export class SimpleWorkerServer {
|
||||
* Called on the worker side
|
||||
*/
|
||||
export function create(postMessage: (msg: string) => void): SimpleWorkerServer {
|
||||
return new SimpleWorkerServer(postMessage);
|
||||
return new SimpleWorkerServer(postMessage, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user