mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -233,6 +233,7 @@ export class ActionRunner implements IActionRunner {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
// noop
|
||||
this._onDidBeforeRun.dispose();
|
||||
this._onDidRun.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,3 +438,20 @@ export function arrayInsert<T>(target: T[], insertIndex: number, insertArr: T[])
|
||||
const after = target.slice(insertIndex);
|
||||
return before.concat(insertArr, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Fisher-Yates shuffle to shuffle the given array
|
||||
* @param array
|
||||
*/
|
||||
export function shuffle<T>(array: T[]): void {
|
||||
var i = 0
|
||||
, j = 0
|
||||
, temp = null;
|
||||
|
||||
for (i = array.length - 1; i > 0; i -= 1) {
|
||||
j = Math.floor(Math.random() * (i + 1));
|
||||
temp = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = temp;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
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';
|
||||
@@ -181,7 +180,7 @@ export class Delayer<T> {
|
||||
private timeout: number;
|
||||
private completionPromise: Promise;
|
||||
private onSuccess: ValueCallback;
|
||||
private task: ITask<T>;
|
||||
private task: ITask<T | TPromise<T>>;
|
||||
|
||||
constructor(public defaultDelay: number) {
|
||||
this.timeout = null;
|
||||
@@ -190,7 +189,7 @@ export class Delayer<T> {
|
||||
this.task = null;
|
||||
}
|
||||
|
||||
trigger(task: ITask<T>, delay: number = this.defaultDelay): TPromise<T> {
|
||||
trigger(task: ITask<T | TPromise<T>>, delay: number = this.defaultDelay): TPromise<T> {
|
||||
this.task = task;
|
||||
this.cancelTimeout();
|
||||
|
||||
@@ -255,7 +254,7 @@ export class ThrottledDelayer<T> extends Delayer<TPromise<T>> {
|
||||
this.throttler = new Throttler();
|
||||
}
|
||||
|
||||
trigger(promiseFactory: ITask<TPromise<T>>, delay?: number): Promise {
|
||||
trigger(promiseFactory: ITask<TPromise<T>>, delay?: number): TPromise {
|
||||
return super.trigger(() => this.throttler.queue(promiseFactory), delay);
|
||||
}
|
||||
}
|
||||
@@ -314,6 +313,13 @@ export class ShallowCancelThenPromise<T> extends TPromise<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replacement for `WinJS.Promise.timeout`.
|
||||
*/
|
||||
export function timeout(n: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new promise that joins the provided promise. Upon completion of
|
||||
* the provided promise the provided function will always be called. This
|
||||
@@ -349,13 +355,14 @@ export function always<T>(promise: TPromise<T>, f: Function): TPromise<T> {
|
||||
* Runs the provided list of promise factories in sequential order. The returned
|
||||
* promise will complete to an array of results from each promise.
|
||||
*/
|
||||
export function sequence<T>(promiseFactories: ITask<TPromise<T>>[]): TPromise<T[]> {
|
||||
|
||||
export function sequence<T>(promiseFactories: ITask<Thenable<T>>[]): TPromise<T[]> {
|
||||
const results: T[] = [];
|
||||
|
||||
// reverse since we start with last element using pop()
|
||||
promiseFactories = promiseFactories.reverse();
|
||||
|
||||
function next(): Promise {
|
||||
function next(): Thenable<any> {
|
||||
if (promiseFactories.length) {
|
||||
return promiseFactories.pop()();
|
||||
}
|
||||
@@ -363,7 +370,7 @@ export function sequence<T>(promiseFactories: ITask<TPromise<T>>[]): TPromise<T[
|
||||
return null;
|
||||
}
|
||||
|
||||
function thenHandler(result: any): Promise {
|
||||
function thenHandler(result: any): Thenable<any> {
|
||||
if (result !== undefined && result !== null) {
|
||||
results.push(result);
|
||||
}
|
||||
@@ -517,7 +524,7 @@ export function setDisposableTimeout(handler: Function, timeout: number, ...args
|
||||
}
|
||||
|
||||
export class TimeoutTimer extends Disposable {
|
||||
private _token: platform.TimeoutToken;
|
||||
private _token: number;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -531,14 +538,14 @@ export class TimeoutTimer extends Disposable {
|
||||
|
||||
cancel(): void {
|
||||
if (this._token !== -1) {
|
||||
platform.clearTimeout(this._token);
|
||||
clearTimeout(this._token);
|
||||
this._token = -1;
|
||||
}
|
||||
}
|
||||
|
||||
cancelAndSet(runner: () => void, timeout: number): void {
|
||||
this.cancel();
|
||||
this._token = platform.setTimeout(() => {
|
||||
this._token = setTimeout(() => {
|
||||
this._token = -1;
|
||||
runner();
|
||||
}, timeout);
|
||||
@@ -549,7 +556,7 @@ export class TimeoutTimer extends Disposable {
|
||||
// timer is already set
|
||||
return;
|
||||
}
|
||||
this._token = platform.setTimeout(() => {
|
||||
this._token = setTimeout(() => {
|
||||
this._token = -1;
|
||||
runner();
|
||||
}, timeout);
|
||||
@@ -558,7 +565,7 @@ export class TimeoutTimer extends Disposable {
|
||||
|
||||
export class IntervalTimer extends Disposable {
|
||||
|
||||
private _token: platform.IntervalToken;
|
||||
private _token: number;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -572,14 +579,14 @@ export class IntervalTimer extends Disposable {
|
||||
|
||||
cancel(): void {
|
||||
if (this._token !== -1) {
|
||||
platform.clearInterval(this._token);
|
||||
clearInterval(this._token);
|
||||
this._token = -1;
|
||||
}
|
||||
}
|
||||
|
||||
cancelAndSet(runner: () => void, interval: number): void {
|
||||
this.cancel();
|
||||
this._token = platform.setInterval(() => {
|
||||
this._token = setInterval(() => {
|
||||
runner();
|
||||
}, interval);
|
||||
}
|
||||
@@ -587,7 +594,7 @@ export class IntervalTimer extends Disposable {
|
||||
|
||||
export class RunOnceScheduler {
|
||||
|
||||
private timeoutToken: platform.TimeoutToken;
|
||||
private timeoutToken: number;
|
||||
private runner: () => void;
|
||||
private timeout: number;
|
||||
private timeoutHandler: () => void;
|
||||
@@ -612,7 +619,7 @@ export class RunOnceScheduler {
|
||||
*/
|
||||
cancel(): void {
|
||||
if (this.isScheduled()) {
|
||||
platform.clearTimeout(this.timeoutToken);
|
||||
clearTimeout(this.timeoutToken);
|
||||
this.timeoutToken = -1;
|
||||
}
|
||||
}
|
||||
@@ -622,7 +629,7 @@ export class RunOnceScheduler {
|
||||
*/
|
||||
schedule(delay = this.timeout): void {
|
||||
this.cancel();
|
||||
this.timeoutToken = platform.setTimeout(this.timeoutHandler, delay);
|
||||
this.timeoutToken = setTimeout(this.timeoutHandler, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -692,4 +699,4 @@ export class ThrottledEmitter<T> extends Emitter<T> {
|
||||
this.hasLastEvent = false;
|
||||
this.lastEvent = void 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,6 +399,22 @@ export class Color {
|
||||
return new Color(new RGBA(r, g, b, a));
|
||||
}
|
||||
|
||||
flatten(...backgrounds: Color[]): Color {
|
||||
const background = backgrounds.reduceRight((accumulator, color) => {
|
||||
return Color._flatten(color, accumulator);
|
||||
});
|
||||
return Color._flatten(this, background);
|
||||
}
|
||||
|
||||
private static _flatten(foreground: Color, background: Color) {
|
||||
const backgroundAlpha = 1 - foreground.rgba.a;
|
||||
return new Color(new RGBA(
|
||||
backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r,
|
||||
backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g,
|
||||
backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b
|
||||
));
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return Color.Format.CSS.format(this);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export function setFileNameComparer(collator: Intl.Collator): void {
|
||||
intlFileNameCollatorIsNumeric = collator.resolvedOptions().numeric;
|
||||
}
|
||||
|
||||
export function compareFileNames(one: string, other: string): number {
|
||||
export function compareFileNames(one: string, other: string, caseSensitive = false): number {
|
||||
if (intlFileNameCollator) {
|
||||
const a = one || '';
|
||||
const b = other || '';
|
||||
@@ -30,14 +30,19 @@ export function compareFileNames(one: string, other: string): number {
|
||||
return result;
|
||||
}
|
||||
|
||||
return noIntlCompareFileNames(one, other);
|
||||
return noIntlCompareFileNames(one, other, caseSensitive);
|
||||
}
|
||||
|
||||
const FileNameMatch = /^(.*?)(\.([^.]*))?$/;
|
||||
|
||||
export function noIntlCompareFileNames(one: string, other: string): number {
|
||||
const [oneName, oneExtension] = extractNameAndExtension(one, true);
|
||||
const [otherName, otherExtension] = extractNameAndExtension(other, true);
|
||||
export function noIntlCompareFileNames(one: string, other: string, caseSensitive = false): number {
|
||||
if (!caseSensitive) {
|
||||
one = one && one.toLowerCase();
|
||||
other = other && other.toLowerCase();
|
||||
}
|
||||
|
||||
const [oneName, oneExtension] = extractNameAndExtension(one);
|
||||
const [otherName, otherExtension] = extractNameAndExtension(other);
|
||||
|
||||
if (oneName !== otherName) {
|
||||
return oneName < otherName ? -1 : 1;
|
||||
@@ -79,8 +84,8 @@ export function compareFileExtensions(one: string, other: string): number {
|
||||
}
|
||||
|
||||
function noIntlCompareFileExtensions(one: string, other: string): number {
|
||||
const [oneName, oneExtension] = extractNameAndExtension(one, true);
|
||||
const [otherName, otherExtension] = extractNameAndExtension(other, true);
|
||||
const [oneName, oneExtension] = extractNameAndExtension(one && one.toLowerCase());
|
||||
const [otherName, otherExtension] = extractNameAndExtension(other && other.toLowerCase());
|
||||
|
||||
if (oneExtension !== otherExtension) {
|
||||
return oneExtension < otherExtension ? -1 : 1;
|
||||
@@ -93,32 +98,49 @@ function noIntlCompareFileExtensions(one: string, other: string): number {
|
||||
return oneName < otherName ? -1 : 1;
|
||||
}
|
||||
|
||||
function extractNameAndExtension(str?: string, lowercase?: boolean): [string, string] {
|
||||
const match = str ? FileNameMatch.exec(lowercase ? str.toLowerCase() : str) : [] as RegExpExecArray;
|
||||
function extractNameAndExtension(str?: string): [string, string] {
|
||||
const match = str ? FileNameMatch.exec(str) : [] as RegExpExecArray;
|
||||
|
||||
return [(match && match[1]) || '', (match && match[3]) || ''];
|
||||
}
|
||||
|
||||
export function comparePaths(one: string, other: string): number {
|
||||
function comparePathComponents(one: string, other: string, caseSensitive = false): number {
|
||||
if (!caseSensitive) {
|
||||
one = one && one.toLowerCase();
|
||||
other = other && other.toLowerCase();
|
||||
}
|
||||
|
||||
if (one === other) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return one < other ? -1 : 1;
|
||||
}
|
||||
|
||||
export function comparePaths(one: string, other: string, caseSensitive = false): number {
|
||||
const oneParts = one.split(paths.nativeSep);
|
||||
const otherParts = other.split(paths.nativeSep);
|
||||
|
||||
const lastOne = oneParts.length - 1;
|
||||
const lastOther = otherParts.length - 1;
|
||||
let endOne: boolean, endOther: boolean, onePart: string, otherPart: string;
|
||||
let endOne: boolean, endOther: boolean;
|
||||
|
||||
for (let i = 0; ; i++) {
|
||||
endOne = lastOne === i;
|
||||
endOther = lastOther === i;
|
||||
|
||||
if (endOne && endOther) {
|
||||
return compareFileNames(oneParts[i], otherParts[i]);
|
||||
return compareFileNames(oneParts[i], otherParts[i], caseSensitive);
|
||||
} else if (endOne) {
|
||||
return -1;
|
||||
} else if (endOther) {
|
||||
return 1;
|
||||
} else if ((onePart = oneParts[i].toLowerCase()) !== (otherPart = otherParts[i].toLowerCase())) {
|
||||
return onePart < otherPart ? -1 : 1;
|
||||
}
|
||||
|
||||
const result = comparePathComponents(oneParts[i], otherParts[i], caseSensitive);
|
||||
|
||||
if (result !== 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export function register(what: string, fn: Function): (...args: any[]) => void {
|
||||
const thisArguments = allArgs.shift();
|
||||
fn.apply(fn, thisArguments);
|
||||
if (allArgs.length > 0) {
|
||||
Platform.setTimeout(doIt, 500);
|
||||
setTimeout(doIt, 500);
|
||||
}
|
||||
};
|
||||
doIt();
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { DiffChange } from 'vs/base/common/diff/diffChange';
|
||||
|
||||
export interface ISequence {
|
||||
getLength(): number;
|
||||
getElementHash(index: number): string;
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
export interface IDiffChange {
|
||||
/**
|
||||
* The position of the first element in the original sequence which
|
||||
* this change affects.
|
||||
*/
|
||||
originalStart: number;
|
||||
|
||||
/**
|
||||
* The number of elements from the original sequence which were
|
||||
* affected.
|
||||
*/
|
||||
originalLength: number;
|
||||
|
||||
/**
|
||||
* The position of the first element in the modified sequence which
|
||||
* this change affects.
|
||||
*/
|
||||
modifiedStart: number;
|
||||
|
||||
/**
|
||||
* The number of elements from the modified sequence which were
|
||||
* affected (added).
|
||||
*/
|
||||
modifiedLength: number;
|
||||
}
|
||||
|
||||
export interface IContinueProcessingPredicate {
|
||||
(furthestOriginalIndex: number, originalSequence: ISequence, matchLengthOfLongest: number): boolean;
|
||||
}
|
||||
|
||||
export interface IHashFunction {
|
||||
(sequence: ISequence, index: number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of the difference algorithm described by Hirschberg
|
||||
*/
|
||||
export class LcsDiff2 {
|
||||
|
||||
private x: ISequence;
|
||||
private y: ISequence;
|
||||
|
||||
private ids_for_x: number[];
|
||||
private ids_for_y: number[];
|
||||
|
||||
private resultX: boolean[];
|
||||
private resultY: boolean[];
|
||||
private forwardPrev: number[];
|
||||
private forwardCurr: number[];
|
||||
private backwardPrev: number[];
|
||||
private backwardCurr: number[];
|
||||
|
||||
constructor(originalSequence: ISequence, newSequence: ISequence, continueProcessingPredicate: IContinueProcessingPredicate, hashFunc: IHashFunction) {
|
||||
this.x = originalSequence;
|
||||
this.y = newSequence;
|
||||
this.ids_for_x = [];
|
||||
this.ids_for_y = [];
|
||||
|
||||
this.resultX = [];
|
||||
this.resultY = [];
|
||||
this.forwardPrev = [];
|
||||
this.forwardCurr = [];
|
||||
this.backwardPrev = [];
|
||||
this.backwardCurr = [];
|
||||
|
||||
for (let i = 0, length = this.x.getLength(); i < length; i++) {
|
||||
this.resultX[i] = false;
|
||||
}
|
||||
|
||||
for (let i = 0, length = this.y.getLength(); i <= length; i++) {
|
||||
this.resultY[i] = false;
|
||||
}
|
||||
|
||||
this.ComputeUniqueIdentifiers();
|
||||
}
|
||||
|
||||
private ComputeUniqueIdentifiers() {
|
||||
let xLength = this.x.getLength();
|
||||
let yLength = this.y.getLength();
|
||||
this.ids_for_x = new Array<number>(xLength);
|
||||
this.ids_for_y = new Array<number>(yLength);
|
||||
|
||||
// Create a new hash table for unique elements from the original
|
||||
// sequence.
|
||||
let hashTable: { [key: string]: number; } = {};
|
||||
let currentUniqueId = 1;
|
||||
let i: number;
|
||||
|
||||
// Fill up the hash table for unique elements
|
||||
for (i = 0; i < xLength; i++) {
|
||||
let xElementHash = this.x.getElementHash(i);
|
||||
if (!hashTable.hasOwnProperty(xElementHash)) {
|
||||
// No entry in the hashtable so this is a new unique element.
|
||||
// Assign the element a new unique identifier and add it to the
|
||||
// hash table
|
||||
this.ids_for_x[i] = currentUniqueId++;
|
||||
hashTable[xElementHash] = this.ids_for_x[i];
|
||||
} else {
|
||||
this.ids_for_x[i] = hashTable[xElementHash];
|
||||
}
|
||||
}
|
||||
|
||||
// Now match up modified elements
|
||||
for (i = 0; i < yLength; i++) {
|
||||
let yElementHash = this.y.getElementHash(i);
|
||||
if (!hashTable.hasOwnProperty(yElementHash)) {
|
||||
this.ids_for_y[i] = currentUniqueId++;
|
||||
hashTable[yElementHash] = this.ids_for_y[i];
|
||||
} else {
|
||||
this.ids_for_y[i] = hashTable[yElementHash];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ElementsAreEqual(xIndex: number, yIndex: number): boolean {
|
||||
return this.ids_for_x[xIndex] === this.ids_for_y[yIndex];
|
||||
}
|
||||
|
||||
public ComputeDiff(): IDiffChange[] {
|
||||
let xLength = this.x.getLength();
|
||||
let yLength = this.y.getLength();
|
||||
|
||||
this.execute(0, xLength - 1, 0, yLength - 1);
|
||||
|
||||
// Construct the changes
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
let xChangeStart: number, yChangeStart: number;
|
||||
let changes: DiffChange[] = [];
|
||||
while (i < xLength && j < yLength) {
|
||||
if (this.resultX[i] && this.resultY[j]) {
|
||||
// No change
|
||||
i++;
|
||||
j++;
|
||||
} else {
|
||||
xChangeStart = i;
|
||||
yChangeStart = j;
|
||||
while (i < xLength && !this.resultX[i]) {
|
||||
i++;
|
||||
}
|
||||
while (j < yLength && !this.resultY[j]) {
|
||||
j++;
|
||||
}
|
||||
changes.push(new DiffChange(xChangeStart, i - xChangeStart, yChangeStart, j - yChangeStart));
|
||||
}
|
||||
}
|
||||
if (i < xLength) {
|
||||
changes.push(new DiffChange(i, xLength - i, yLength, 0));
|
||||
}
|
||||
if (j < yLength) {
|
||||
changes.push(new DiffChange(xLength, 0, j, yLength - j));
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
private forward(xStart: number, xStop: number, yStart: number, yStop: number): number[] {
|
||||
let prev = this.forwardPrev,
|
||||
curr = this.forwardCurr,
|
||||
tmp: number[],
|
||||
i: number,
|
||||
j: number;
|
||||
|
||||
// First line
|
||||
prev[yStart] = this.ElementsAreEqual(xStart, yStart) ? 1 : 0;
|
||||
for (j = yStart + 1; j <= yStop; j++) {
|
||||
prev[j] = this.ElementsAreEqual(xStart, j) ? 1 : prev[j - 1];
|
||||
}
|
||||
|
||||
for (i = xStart + 1; i <= xStop; i++) {
|
||||
// First column
|
||||
curr[yStart] = this.ElementsAreEqual(i, yStart) ? 1 : prev[yStart];
|
||||
|
||||
for (j = yStart + 1; j <= yStop; j++) {
|
||||
if (this.ElementsAreEqual(i, j)) {
|
||||
curr[j] = prev[j - 1] + 1;
|
||||
} else {
|
||||
curr[j] = prev[j] > curr[j - 1] ? prev[j] : curr[j - 1];
|
||||
}
|
||||
}
|
||||
|
||||
// Swap prev & curr
|
||||
tmp = curr;
|
||||
curr = prev;
|
||||
prev = tmp;
|
||||
}
|
||||
|
||||
// Result is always in prev
|
||||
return prev;
|
||||
}
|
||||
|
||||
private backward(xStart: number, xStop: number, yStart: number, yStop: number): number[] {
|
||||
let prev = this.backwardPrev,
|
||||
curr = this.backwardCurr,
|
||||
tmp: number[],
|
||||
i: number,
|
||||
j: number;
|
||||
|
||||
// Last line
|
||||
prev[yStop] = this.ElementsAreEqual(xStop, yStop) ? 1 : 0;
|
||||
for (j = yStop - 1; j >= yStart; j--) {
|
||||
prev[j] = this.ElementsAreEqual(xStop, j) ? 1 : prev[j + 1];
|
||||
}
|
||||
|
||||
for (i = xStop - 1; i >= xStart; i--) {
|
||||
// Last column
|
||||
curr[yStop] = this.ElementsAreEqual(i, yStop) ? 1 : prev[yStop];
|
||||
|
||||
for (j = yStop - 1; j >= yStart; j--) {
|
||||
if (this.ElementsAreEqual(i, j)) {
|
||||
curr[j] = prev[j + 1] + 1;
|
||||
} else {
|
||||
curr[j] = prev[j] > curr[j + 1] ? prev[j] : curr[j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
// Swap prev & curr
|
||||
tmp = curr;
|
||||
curr = prev;
|
||||
prev = tmp;
|
||||
}
|
||||
|
||||
// Result is always in prev
|
||||
return prev;
|
||||
}
|
||||
|
||||
private findCut(xStart: number, xStop: number, yStart: number, yStop: number, middle: number): number {
|
||||
let L1 = this.forward(xStart, middle, yStart, yStop);
|
||||
let L2 = this.backward(middle + 1, xStop, yStart, yStop);
|
||||
|
||||
// First cut
|
||||
let max = L2[yStart], cut = yStart - 1;
|
||||
|
||||
// Middle cut
|
||||
for (let j = yStart; j < yStop; j++) {
|
||||
if (L1[j] + L2[j + 1] > max) {
|
||||
max = L1[j] + L2[j + 1];
|
||||
cut = j;
|
||||
}
|
||||
}
|
||||
|
||||
// Last cut
|
||||
if (L1[yStop] > max) {
|
||||
max = L1[yStop];
|
||||
cut = yStop;
|
||||
}
|
||||
|
||||
return cut;
|
||||
}
|
||||
|
||||
private execute(xStart: number, xStop: number, yStart: number, yStop: number) {
|
||||
// Do some prefix trimming
|
||||
while (xStart <= xStop && yStart <= yStop && this.ElementsAreEqual(xStart, yStart)) {
|
||||
this.resultX[xStart] = true;
|
||||
xStart++;
|
||||
this.resultY[yStart] = true;
|
||||
yStart++;
|
||||
}
|
||||
|
||||
// Do some suffix trimming
|
||||
while (xStart <= xStop && yStart <= yStop && this.ElementsAreEqual(xStop, yStop)) {
|
||||
this.resultX[xStop] = true;
|
||||
xStop--;
|
||||
this.resultY[yStop] = true;
|
||||
yStop--;
|
||||
}
|
||||
|
||||
if (xStart > xStop || yStart > yStop) {
|
||||
return;
|
||||
}
|
||||
|
||||
let found: number, i: number;
|
||||
if (xStart === xStop) {
|
||||
found = -1;
|
||||
for (i = yStart; i <= yStop; i++) {
|
||||
if (this.ElementsAreEqual(xStart, i)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found >= 0) {
|
||||
this.resultX[xStart] = true;
|
||||
this.resultY[found] = true;
|
||||
}
|
||||
} else if (yStart === yStop) {
|
||||
found = -1;
|
||||
for (i = xStart; i <= xStop; i++) {
|
||||
if (this.ElementsAreEqual(i, yStart)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found >= 0) {
|
||||
this.resultX[found] = true;
|
||||
this.resultY[yStart] = true;
|
||||
}
|
||||
} else {
|
||||
let middle = Math.floor((xStart + xStop) / 2);
|
||||
let cut = this.findCut(xStart, xStop, yStart, yStop, middle);
|
||||
|
||||
if (yStart <= cut) {
|
||||
this.execute(xStart, middle, yStart, cut);
|
||||
}
|
||||
|
||||
if (cut + 1 <= yStop) {
|
||||
this.execute(middle + 1, xStop, cut + 1, yStop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import platform = require('vs/base/common/platform');
|
||||
import types = require('vs/base/common/types');
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { TPromise, IPromiseError, IPromiseErrorDetail } from 'vs/base/common/winjs.base';
|
||||
|
||||
// ------ BEGIN Hook up error listeners to winjs promises
|
||||
@@ -79,7 +76,7 @@ export class ErrorHandler {
|
||||
this.listeners = [];
|
||||
|
||||
this.unexpectedErrorHandler = function (e: any) {
|
||||
platform.setTimeout(() => {
|
||||
setTimeout(() => {
|
||||
if (e.stack) {
|
||||
throw new Error(e.message + '\n\n' + e.stack);
|
||||
}
|
||||
@@ -238,19 +235,22 @@ export function disposed(what: string): Error {
|
||||
}
|
||||
|
||||
export interface IErrorOptions {
|
||||
severity?: Severity;
|
||||
actions?: IAction[];
|
||||
}
|
||||
|
||||
export function create(message: string, options: IErrorOptions = {}): Error {
|
||||
let result = new Error(message);
|
||||
export interface IErrorWithActions {
|
||||
actions?: IAction[];
|
||||
}
|
||||
|
||||
if (types.isNumber(options.severity)) {
|
||||
(<any>result).severity = options.severity;
|
||||
}
|
||||
export function isErrorWithActions(obj: any): obj is IErrorWithActions {
|
||||
return obj instanceof Error && Array.isArray((obj as IErrorWithActions).actions);
|
||||
}
|
||||
|
||||
export function create(message: string, options: IErrorOptions = Object.create(null)): Error & IErrorWithActions {
|
||||
const result = new Error(message);
|
||||
|
||||
if (options.actions) {
|
||||
(<any>result).actions = options.actions;
|
||||
(<IErrorWithActions>result).actions = options.actions;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -341,6 +341,22 @@ export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSep
|
||||
return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
|
||||
}
|
||||
|
||||
export function skipScore(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): [number, number[]] {
|
||||
pattern = pattern.toLowerCase();
|
||||
word = word.toLowerCase();
|
||||
|
||||
const matches: number[] = [];
|
||||
let idx = 0;
|
||||
for (let pos = 0; pos < pattern.length; ++pos) {
|
||||
const thisIdx = word.indexOf(pattern.charAt(pos), idx);
|
||||
if (thisIdx >= 0) {
|
||||
matches.push(thisIdx);
|
||||
idx = thisIdx + 1;
|
||||
}
|
||||
}
|
||||
return [matches.length, matches];
|
||||
}
|
||||
|
||||
//#region --- fuzzyScore ---
|
||||
|
||||
export function createMatches(position: number[]): IMatch[] {
|
||||
@@ -560,7 +576,7 @@ export function fuzzyScore(pattern: string, word: string, patternMaxWhitespaceIg
|
||||
_matchesCount = 0;
|
||||
_topScore = -100;
|
||||
_patternStartPos = patternStartPos;
|
||||
_findAllMatches(patternLen, wordLen, 0, new LazyArray(), false);
|
||||
_findAllMatches(patternLen, wordLen, patternLen === wordLen ? 1 : 0, new LazyArray(), false);
|
||||
|
||||
if (_matchesCount === 0) {
|
||||
return undefined;
|
||||
|
||||
@@ -220,8 +220,12 @@ function parseRegExp(pattern: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// Tail: Add the slash we had split on if there is more to come and the next one is not a globstar
|
||||
if (index < segments.length - 1 && segments[index + 1] !== GLOBSTAR) {
|
||||
// Tail: Add the slash we had split on if there is more to come and the remaining pattern is not a globstar
|
||||
// For example if pattern: some/**/*.js we want the "/" after some to be included in the RegEx to prevent
|
||||
// a folder called "something" to match as well.
|
||||
// However, if pattern: some/**, we tolerate that we also match on "something" because our globstar behaviour
|
||||
// is to match 0-N segments.
|
||||
if (index < segments.length - 1 && (segments[index + 1] !== GLOBSTAR || index + 2 < segments.length)) {
|
||||
regEx += PATH_REGEX;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ 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 { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export interface IWorkspaceFolderProvider {
|
||||
getWorkspaceFolder(resource: URI): { uri: URI };
|
||||
@@ -29,8 +30,8 @@ export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFo
|
||||
resource = URI.file(resource);
|
||||
}
|
||||
|
||||
if (resource.scheme !== 'file' && resource.scheme !== 'untitled') {
|
||||
return resource.authority + resource.path;
|
||||
if (resource.scheme !== Schemas.file && resource.scheme !== Schemas.untitled) {
|
||||
return resource.with({ query: null, fragment: null }).toString(true);
|
||||
}
|
||||
|
||||
// return early if we can resolve a relative path label from the root
|
||||
@@ -362,4 +363,4 @@ export function mnemonicButtonLabel(label: string): string {
|
||||
|
||||
export function unmnemonicLabel(label: string): string {
|
||||
return label.replace(/&/g, '&&');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
export function values<K, V>(map: Map<K, V>): V[] {
|
||||
export function values<V = any>(set: Set<V>): V[];
|
||||
export function values<K = any, V = any>(map: Map<K, V>): V[];
|
||||
export function values<V>(forEachable: { forEach(callback: (value: V, ...more: any[]) => any) }): V[] {
|
||||
const result: V[] = [];
|
||||
map.forEach(value => result.push(value));
|
||||
|
||||
forEachable.forEach(value => result.push(value));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
[{
|
||||
"name": "chjj-marked",
|
||||
"repositoryURL": "https://github.com/npmcomponent/chjj-marked",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.12",
|
||||
"license": "MIT"
|
||||
}]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* marked - a markdown parser
|
||||
* Copyright (c) 2011-2014, Christopher Jeffrey. (Source EULAd)
|
||||
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/chjj/marked
|
||||
*/
|
||||
|
||||
@@ -16,19 +16,26 @@ var block = {
|
||||
newline: /^\n+/,
|
||||
code: /^( {4}[^\n]+\n*)+/,
|
||||
fences: noop,
|
||||
hr: /^( *[-*_]){3,} *(?:\n+|$)/,
|
||||
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
||||
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
||||
nptable: noop,
|
||||
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
||||
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
||||
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
||||
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
||||
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
||||
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
||||
table: noop,
|
||||
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
|
||||
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
||||
paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,
|
||||
text: /^[^\n]+/
|
||||
};
|
||||
|
||||
block._label = /(?:\\[\[\]]|[^\[\]])+/;
|
||||
block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/;
|
||||
block.def = replace(block.def)
|
||||
('label', block._label)
|
||||
('title', block._title)
|
||||
();
|
||||
|
||||
block.bullet = /(?:[*+-]|\d+\.)/;
|
||||
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
||||
block.item = replace(block.item, 'gm')
|
||||
@@ -37,23 +44,19 @@ block.item = replace(block.item, 'gm')
|
||||
|
||||
block.list = replace(block.list)
|
||||
(/bull/g, block.bullet)
|
||||
('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
|
||||
('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
||||
('def', '\\n+(?=' + block.def.source + ')')
|
||||
();
|
||||
|
||||
block.blockquote = replace(block.blockquote)
|
||||
('def', block.def)
|
||||
();
|
||||
|
||||
block._tag = '(?!(?:'
|
||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
||||
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
||||
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
|
||||
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b';
|
||||
|
||||
block.html = replace(block.html)
|
||||
('comment', /<!--[\s\S]*?-->/)
|
||||
('closed', /<(tag)[\s\S]+?<\/\1>/)
|
||||
('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
||||
('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>]*)*?\/?>/)
|
||||
(/tag/g, block._tag)
|
||||
();
|
||||
|
||||
@@ -61,9 +64,11 @@ block.paragraph = replace(block.paragraph)
|
||||
('hr', block.hr)
|
||||
('heading', block.heading)
|
||||
('lheading', block.lheading)
|
||||
('blockquote', block.blockquote)
|
||||
('tag', '<' + block._tag)
|
||||
('def', block.def)
|
||||
();
|
||||
|
||||
block.blockquote = replace(block.blockquote)
|
||||
('paragraph', block.paragraph)
|
||||
();
|
||||
|
||||
/**
|
||||
@@ -77,15 +82,15 @@ block.normal = merge({}, block);
|
||||
*/
|
||||
|
||||
block.gfm = merge({}, block.normal, {
|
||||
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
|
||||
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
|
||||
paragraph: /^/,
|
||||
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
||||
});
|
||||
|
||||
block.gfm.paragraph = replace(block.paragraph)
|
||||
('(?!', '(?!'
|
||||
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
||||
+ block.list.source.replace('\\1', '\\3') + '|')
|
||||
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
||||
+ block.list.source.replace('\\1', '\\3') + '|')
|
||||
();
|
||||
|
||||
/**
|
||||
@@ -126,7 +131,7 @@ Lexer.rules = block;
|
||||
* Static Lex Method
|
||||
*/
|
||||
|
||||
Lexer.lex = function(src, options) {
|
||||
Lexer.lex = function (src, options) {
|
||||
var lexer = new Lexer(options);
|
||||
return lexer.lex(src);
|
||||
};
|
||||
@@ -135,7 +140,7 @@ Lexer.lex = function(src, options) {
|
||||
* Preprocessing
|
||||
*/
|
||||
|
||||
Lexer.prototype.lex = function(src) {
|
||||
Lexer.prototype.lex = function (src) {
|
||||
src = src
|
||||
.replace(/\r\n|\r/g, '\n')
|
||||
.replace(/\t/g, ' ')
|
||||
@@ -149,7 +154,7 @@ Lexer.prototype.lex = function(src) {
|
||||
* Lexing
|
||||
*/
|
||||
|
||||
Lexer.prototype.token = function(src, top, bq) {
|
||||
Lexer.prototype.token = function (src, top) {
|
||||
var src = src.replace(/^ +$/gm, '')
|
||||
, next
|
||||
, loose
|
||||
@@ -159,6 +164,7 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
, item
|
||||
, space
|
||||
, i
|
||||
, tag
|
||||
, l;
|
||||
|
||||
while (src) {
|
||||
@@ -239,17 +245,6 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// lheading
|
||||
if (cap = this.rules.lheading.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
this.tokens.push({
|
||||
type: 'heading',
|
||||
depth: cap[2] === '=' ? 1 : 2,
|
||||
text: cap[1]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// hr
|
||||
if (cap = this.rules.hr.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
@@ -272,7 +267,7 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
// Pass `top` to keep the current
|
||||
// "toplevel" state. This is exactly
|
||||
// how markdown.pl works.
|
||||
this.token(cap, top, true);
|
||||
this.token(cap, top);
|
||||
|
||||
this.tokens.push({
|
||||
type: 'blockquote_end'
|
||||
@@ -341,7 +336,7 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
});
|
||||
|
||||
// Recurse.
|
||||
this.token(item, false, bq);
|
||||
this.token(item, false);
|
||||
|
||||
this.tokens.push({
|
||||
type: 'list_item_end'
|
||||
@@ -370,12 +365,16 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
}
|
||||
|
||||
// def
|
||||
if ((!bq && top) && (cap = this.rules.def.exec(src))) {
|
||||
if (top && (cap = this.rules.def.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
this.tokens.links[cap[1].toLowerCase()] = {
|
||||
href: cap[2],
|
||||
title: cap[3]
|
||||
};
|
||||
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
||||
tag = cap[1].toLowerCase();
|
||||
if (!this.tokens.links[tag]) {
|
||||
this.tokens.links[tag] = {
|
||||
href: cap[2],
|
||||
title: cap[3]
|
||||
};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -413,6 +412,17 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// lheading
|
||||
if (cap = this.rules.lheading.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
this.tokens.push({
|
||||
type: 'heading',
|
||||
depth: cap[2] === '=' ? 1 : 2,
|
||||
text: cap[1]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// top-level paragraph
|
||||
if (top && (cap = this.rules.paragraph.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
@@ -451,21 +461,29 @@ Lexer.prototype.token = function(src, top, bq) {
|
||||
|
||||
var inline = {
|
||||
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
||||
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
||||
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
||||
url: noop,
|
||||
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
||||
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/]*)*?\/?>/,
|
||||
link: /^!?\[(inside)\]\(href\)/,
|
||||
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
||||
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
||||
nolink: /^!?\[((?:\[[^\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
|
||||
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
||||
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
||||
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
||||
em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
|
||||
code: /^(`+)(\s*)([\s\S]*?[^`]?)\2\1(?!`)/,
|
||||
br: /^ {2,}\n(?!\s*$)/,
|
||||
del: noop,
|
||||
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
||||
text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
|
||||
};
|
||||
|
||||
inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
|
||||
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
||||
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
||||
|
||||
inline.autolink = replace(inline.autolink)
|
||||
('scheme', inline._scheme)
|
||||
('email', inline._email)
|
||||
()
|
||||
|
||||
inline._inside = /(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
|
||||
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
||||
|
||||
inline.link = replace(inline.link)
|
||||
@@ -498,11 +516,14 @@ inline.pedantic = merge({}, inline.normal, {
|
||||
|
||||
inline.gfm = merge({}, inline.normal, {
|
||||
escape: replace(inline.escape)('])', '~|])')(),
|
||||
url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
|
||||
url: replace(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
|
||||
('email', inline._email)
|
||||
(),
|
||||
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
||||
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
||||
text: replace(inline.text)
|
||||
(']|', '~]|')
|
||||
('|', '|https?://|')
|
||||
('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
|
||||
()
|
||||
});
|
||||
|
||||
@@ -552,7 +573,7 @@ InlineLexer.rules = inline;
|
||||
* Static Lexing/Compiling Method
|
||||
*/
|
||||
|
||||
InlineLexer.output = function(src, links, options) {
|
||||
InlineLexer.output = function (src, links, options) {
|
||||
var inline = new InlineLexer(links, options);
|
||||
return inline.output(src);
|
||||
};
|
||||
@@ -561,7 +582,7 @@ InlineLexer.output = function(src, links, options) {
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
|
||||
InlineLexer.prototype.output = function(src) {
|
||||
InlineLexer.prototype.output = function (src) {
|
||||
var out = ''
|
||||
, link
|
||||
, text
|
||||
@@ -580,10 +601,8 @@ InlineLexer.prototype.output = function(src) {
|
||||
if (cap = this.rules.autolink.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
if (cap[2] === '@') {
|
||||
text = cap[1].charAt(6) === ':'
|
||||
? this.mangle(cap[1].substring(7))
|
||||
: this.mangle(cap[1]);
|
||||
href = this.mangle('mailto:') + text;
|
||||
text = escape(this.mangle(cap[1]));
|
||||
href = 'mailto:' + text;
|
||||
} else {
|
||||
text = escape(cap[1]);
|
||||
href = text;
|
||||
@@ -594,9 +613,19 @@ InlineLexer.prototype.output = function(src) {
|
||||
|
||||
// url (gfm)
|
||||
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
||||
cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
||||
src = src.substring(cap[0].length);
|
||||
text = escape(cap[1]);
|
||||
href = text;
|
||||
if (cap[2] === '@') {
|
||||
text = escape(cap[0]);
|
||||
href = 'mailto:' + text;
|
||||
} else {
|
||||
text = escape(cap[0]);
|
||||
if (cap[1] === 'www.') {
|
||||
href = 'http://' + text;
|
||||
} else {
|
||||
href = text;
|
||||
}
|
||||
}
|
||||
out += this.renderer.link(href, null, text);
|
||||
continue;
|
||||
}
|
||||
@@ -631,7 +660,7 @@ InlineLexer.prototype.output = function(src) {
|
||||
|
||||
// reflink, nolink
|
||||
if ((cap = this.rules.reflink.exec(src))
|
||||
|| (cap = this.rules.nolink.exec(src))) {
|
||||
|| (cap = this.rules.nolink.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
||||
link = this.links[link.toLowerCase()];
|
||||
@@ -663,7 +692,7 @@ InlineLexer.prototype.output = function(src) {
|
||||
// code
|
||||
if (cap = this.rules.code.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += this.renderer.codespan(escape(cap[2], true));
|
||||
out += this.renderer.codespan(escape(cap[3].trim(), true));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -701,7 +730,7 @@ InlineLexer.prototype.output = function(src) {
|
||||
* Compile Link
|
||||
*/
|
||||
|
||||
InlineLexer.prototype.outputLink = function(cap, link) {
|
||||
InlineLexer.prototype.outputLink = function (cap, link) {
|
||||
var href = escape(link.href)
|
||||
, title = link.title ? escape(link.title) : null;
|
||||
|
||||
@@ -714,7 +743,7 @@ InlineLexer.prototype.outputLink = function(cap, link) {
|
||||
* Smartypants Transformations
|
||||
*/
|
||||
|
||||
InlineLexer.prototype.smartypants = function(text) {
|
||||
InlineLexer.prototype.smartypants = function (text) {
|
||||
if (!this.options.smartypants) return text;
|
||||
return text
|
||||
// em-dashes
|
||||
@@ -737,7 +766,7 @@ InlineLexer.prototype.smartypants = function(text) {
|
||||
* Mangle Links
|
||||
*/
|
||||
|
||||
InlineLexer.prototype.mangle = function(text) {
|
||||
InlineLexer.prototype.mangle = function (text) {
|
||||
if (!this.options.mangle) return text;
|
||||
var out = ''
|
||||
, l = text.length
|
||||
@@ -763,7 +792,7 @@ function Renderer(options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
|
||||
Renderer.prototype.code = function(code, lang, escaped) {
|
||||
Renderer.prototype.code = function (code, lang, escaped) {
|
||||
if (this.options.highlight) {
|
||||
var out = this.options.highlight(code, lang);
|
||||
if (out != null && out !== code) {
|
||||
@@ -786,15 +815,15 @@ Renderer.prototype.code = function(code, lang, escaped) {
|
||||
+ '\n</code></pre>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.blockquote = function(quote) {
|
||||
Renderer.prototype.blockquote = function (quote) {
|
||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.html = function(html) {
|
||||
Renderer.prototype.html = function (html) {
|
||||
return html;
|
||||
};
|
||||
|
||||
Renderer.prototype.heading = function(text, level, raw) {
|
||||
Renderer.prototype.heading = function (text, level, raw) {
|
||||
return '<h'
|
||||
+ level
|
||||
+ ' id="'
|
||||
@@ -807,24 +836,24 @@ Renderer.prototype.heading = function(text, level, raw) {
|
||||
+ '>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.hr = function() {
|
||||
Renderer.prototype.hr = function () {
|
||||
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.list = function(body, ordered) {
|
||||
Renderer.prototype.list = function (body, ordered) {
|
||||
var type = ordered ? 'ol' : 'ul';
|
||||
return '<' + type + '>\n' + body + '</' + type + '>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.listitem = function(text) {
|
||||
Renderer.prototype.listitem = function (text) {
|
||||
return '<li>' + text + '</li>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.paragraph = function(text) {
|
||||
Renderer.prototype.paragraph = function (text) {
|
||||
return '<p>' + text + '</p>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.table = function(header, body) {
|
||||
Renderer.prototype.table = function (header, body) {
|
||||
return '<table>\n'
|
||||
+ '<thead>\n'
|
||||
+ header
|
||||
@@ -835,11 +864,11 @@ Renderer.prototype.table = function(header, body) {
|
||||
+ '</table>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.tablerow = function(content) {
|
||||
Renderer.prototype.tablerow = function (content) {
|
||||
return '<tr>\n' + content + '</tr>\n';
|
||||
};
|
||||
|
||||
Renderer.prototype.tablecell = function(content, flags) {
|
||||
Renderer.prototype.tablecell = function (content, flags) {
|
||||
var type = flags.header ? 'th' : 'td';
|
||||
var tag = flags.align
|
||||
? '<' + type + ' style="text-align:' + flags.align + '">'
|
||||
@@ -848,39 +877,42 @@ Renderer.prototype.tablecell = function(content, flags) {
|
||||
};
|
||||
|
||||
// span level renderer
|
||||
Renderer.prototype.strong = function(text) {
|
||||
Renderer.prototype.strong = function (text) {
|
||||
return '<strong>' + text + '</strong>';
|
||||
};
|
||||
|
||||
Renderer.prototype.em = function(text) {
|
||||
Renderer.prototype.em = function (text) {
|
||||
return '<em>' + text + '</em>';
|
||||
};
|
||||
|
||||
Renderer.prototype.codespan = function(text) {
|
||||
Renderer.prototype.codespan = function (text) {
|
||||
return '<code>' + text + '</code>';
|
||||
};
|
||||
|
||||
Renderer.prototype.br = function() {
|
||||
Renderer.prototype.br = function () {
|
||||
return this.options.xhtml ? '<br/>' : '<br>';
|
||||
};
|
||||
|
||||
Renderer.prototype.del = function(text) {
|
||||
Renderer.prototype.del = function (text) {
|
||||
return '<del>' + text + '</del>';
|
||||
};
|
||||
|
||||
Renderer.prototype.link = function(href, title, text) {
|
||||
Renderer.prototype.link = function (href, title, text) {
|
||||
if (this.options.sanitize) {
|
||||
try {
|
||||
var prot = decodeURIComponent(unescape(href))
|
||||
.replace(/[^\w:]/g, '')
|
||||
.toLowerCase();
|
||||
} catch (e) {
|
||||
return '';
|
||||
return text;
|
||||
}
|
||||
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
||||
return '';
|
||||
return text;
|
||||
}
|
||||
}
|
||||
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
||||
href = resolveUrl(this.options.baseUrl, href);
|
||||
}
|
||||
var out = '<a href="' + href + '"';
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
@@ -889,7 +921,10 @@ Renderer.prototype.link = function(href, title, text) {
|
||||
return out;
|
||||
};
|
||||
|
||||
Renderer.prototype.image = function(href, title, text) {
|
||||
Renderer.prototype.image = function (href, title, text) {
|
||||
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
||||
href = resolveUrl(this.options.baseUrl, href);
|
||||
}
|
||||
var out = '<img src="' + href + '" alt="' + text + '"';
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
@@ -898,10 +933,36 @@ Renderer.prototype.image = function(href, title, text) {
|
||||
return out;
|
||||
};
|
||||
|
||||
Renderer.prototype.text = function(text) {
|
||||
Renderer.prototype.text = function (text) {
|
||||
return text;
|
||||
};
|
||||
|
||||
/**
|
||||
* TextRenderer
|
||||
* returns only the textual part of the token
|
||||
*/
|
||||
|
||||
function TextRenderer() { }
|
||||
|
||||
// no need for block level renderers
|
||||
|
||||
TextRenderer.prototype.strong =
|
||||
TextRenderer.prototype.em =
|
||||
TextRenderer.prototype.codespan =
|
||||
TextRenderer.prototype.del =
|
||||
TextRenderer.prototype.text = function (text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
TextRenderer.prototype.link =
|
||||
TextRenderer.prototype.image = function (href, title, text) {
|
||||
return '' + text;
|
||||
}
|
||||
|
||||
TextRenderer.prototype.br = function () {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing & Compiling
|
||||
*/
|
||||
@@ -919,8 +980,8 @@ function Parser(options) {
|
||||
* Static Parse Method
|
||||
*/
|
||||
|
||||
Parser.parse = function(src, options, renderer) {
|
||||
var parser = new Parser(options, renderer);
|
||||
Parser.parse = function (src, options) {
|
||||
var parser = new Parser(options);
|
||||
return parser.parse(src);
|
||||
};
|
||||
|
||||
@@ -928,8 +989,10 @@ Parser.parse = function(src, options, renderer) {
|
||||
* Parse Loop
|
||||
*/
|
||||
|
||||
Parser.prototype.parse = function(src) {
|
||||
this.inline = new InlineLexer(src.links, this.options, this.renderer);
|
||||
Parser.prototype.parse = function (src) {
|
||||
this.inline = new InlineLexer(src.links, this.options);
|
||||
// use an InlineLexer with a TextRenderer to extract pure text
|
||||
this.inlineText = new InlineLexer(src.links, merge({}, this.options, { renderer: new TextRenderer }));
|
||||
this.tokens = src.reverse();
|
||||
|
||||
var out = '';
|
||||
@@ -944,7 +1007,7 @@ Parser.prototype.parse = function(src) {
|
||||
* Next Token
|
||||
*/
|
||||
|
||||
Parser.prototype.next = function() {
|
||||
Parser.prototype.next = function () {
|
||||
return this.token = this.tokens.pop();
|
||||
};
|
||||
|
||||
@@ -952,7 +1015,7 @@ Parser.prototype.next = function() {
|
||||
* Preview Next Token
|
||||
*/
|
||||
|
||||
Parser.prototype.peek = function() {
|
||||
Parser.prototype.peek = function () {
|
||||
return this.tokens[this.tokens.length - 1] || 0;
|
||||
};
|
||||
|
||||
@@ -960,7 +1023,7 @@ Parser.prototype.peek = function() {
|
||||
* Parse Text Tokens
|
||||
*/
|
||||
|
||||
Parser.prototype.parseText = function() {
|
||||
Parser.prototype.parseText = function () {
|
||||
var body = this.token.text;
|
||||
|
||||
while (this.peek().type === 'text') {
|
||||
@@ -974,7 +1037,7 @@ Parser.prototype.parseText = function() {
|
||||
* Parse Current Token
|
||||
*/
|
||||
|
||||
Parser.prototype.tok = function() {
|
||||
Parser.prototype.tok = function () {
|
||||
switch (this.token.type) {
|
||||
case 'space': {
|
||||
return '';
|
||||
@@ -986,7 +1049,7 @@ Parser.prototype.tok = function() {
|
||||
return this.renderer.heading(
|
||||
this.inline.output(this.token.text),
|
||||
this.token.depth,
|
||||
this.token.text);
|
||||
unescape(this.inlineText.output(this.token.text)));
|
||||
}
|
||||
case 'code': {
|
||||
return this.renderer.code(this.token.text,
|
||||
@@ -999,13 +1062,11 @@ Parser.prototype.tok = function() {
|
||||
, i
|
||||
, row
|
||||
, cell
|
||||
, flags
|
||||
, j;
|
||||
|
||||
// header
|
||||
cell = '';
|
||||
for (i = 0; i < this.token.header.length; i++) {
|
||||
flags = { header: true, align: this.token.align[i] };
|
||||
cell += this.renderer.tablecell(
|
||||
this.inline.output(this.token.header[i]),
|
||||
{ header: true, align: this.token.align[i] }
|
||||
@@ -1096,8 +1157,8 @@ function escape(html, encode) {
|
||||
}
|
||||
|
||||
function unescape(html) {
|
||||
// explicitly match decimal, hex, and named HTML entities
|
||||
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
|
||||
// explicitly match decimal, hex, and named HTML entities
|
||||
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
|
||||
n = n.toLowerCase();
|
||||
if (n === 'colon') return ':';
|
||||
if (n.charAt(0) === '#') {
|
||||
@@ -1121,7 +1182,31 @@ function replace(regex, opt) {
|
||||
};
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
function resolveUrl(base, href) {
|
||||
if (!baseUrls[' ' + base]) {
|
||||
// we can ignore everything in base after the last slash of its path component,
|
||||
// but we might need to add _that_
|
||||
// https://tools.ietf.org/html/rfc3986#section-3
|
||||
if (/^[^:]+:\/*[^/]*$/.test(base)) {
|
||||
baseUrls[' ' + base] = base + '/';
|
||||
} else {
|
||||
baseUrls[' ' + base] = base.replace(/[^/]*$/, '');
|
||||
}
|
||||
}
|
||||
base = baseUrls[' ' + base];
|
||||
|
||||
if (href.slice(0, 2) === '//') {
|
||||
return base.replace(/:[\s\S]*/, ':') + href;
|
||||
} else if (href.charAt(0) === '/') {
|
||||
return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
|
||||
} else {
|
||||
return base + href;
|
||||
}
|
||||
}
|
||||
var baseUrls = {};
|
||||
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
||||
|
||||
function noop() { }
|
||||
noop.exec = noop;
|
||||
|
||||
function merge(obj) {
|
||||
@@ -1147,6 +1232,14 @@ function merge(obj) {
|
||||
*/
|
||||
|
||||
function marked(src, opt, callback) {
|
||||
// throw error in case of non string input
|
||||
if (typeof src == 'undefined' || src === null)
|
||||
throw new Error('marked(): input parameter is undefined or null');
|
||||
if (typeof src != 'string')
|
||||
throw new Error('marked(): input parameter is of type ' +
|
||||
Object.prototype.toString.call(src) + ', string expected');
|
||||
|
||||
|
||||
if (callback || typeof opt === 'function') {
|
||||
if (!callback) {
|
||||
callback = opt;
|
||||
@@ -1168,7 +1261,7 @@ function marked(src, opt, callback) {
|
||||
|
||||
pending = tokens.length;
|
||||
|
||||
var done = function(err) {
|
||||
var done = function (err) {
|
||||
if (err) {
|
||||
opt.highlight = highlight;
|
||||
return callback(err);
|
||||
@@ -1198,11 +1291,11 @@ function marked(src, opt, callback) {
|
||||
if (!pending) return done();
|
||||
|
||||
for (; i < tokens.length; i++) {
|
||||
(function(token) {
|
||||
(function (token) {
|
||||
if (token.type !== 'code') {
|
||||
return --pending || done();
|
||||
}
|
||||
return highlight(token.text, token.lang, function(err, code) {
|
||||
return highlight(token.text, token.lang, function (err, code) {
|
||||
if (err) return done(err);
|
||||
if (code == null || code === token.text) {
|
||||
return --pending || done();
|
||||
@@ -1235,10 +1328,10 @@ function marked(src, opt, callback) {
|
||||
*/
|
||||
|
||||
marked.options =
|
||||
marked.setOptions = function(opt) {
|
||||
merge(marked.defaults, opt);
|
||||
return marked;
|
||||
};
|
||||
marked.setOptions = function (opt) {
|
||||
merge(marked.defaults, opt);
|
||||
return marked;
|
||||
};
|
||||
|
||||
marked.defaults = {
|
||||
gfm: true,
|
||||
@@ -1255,7 +1348,8 @@ marked.defaults = {
|
||||
smartypants: false,
|
||||
headerPrefix: '',
|
||||
renderer: new Renderer,
|
||||
xhtml: false
|
||||
xhtml: false,
|
||||
baseUrl: null
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1266,6 +1360,7 @@ marked.Parser = Parser;
|
||||
marked.parser = Parser.parse;
|
||||
|
||||
marked.Renderer = Renderer;
|
||||
marked.TextRenderer = TextRenderer;
|
||||
|
||||
marked.Lexer = Lexer;
|
||||
marked.lexer = Lexer.lex;
|
||||
|
||||
@@ -32,7 +32,7 @@ function replacer(key: string, value: any): any {
|
||||
return value;
|
||||
}
|
||||
|
||||
function revive(obj: any, depth: number): any {
|
||||
export function revive(obj: any, depth: number): any {
|
||||
|
||||
if (!obj || depth > 200) {
|
||||
return obj;
|
||||
@@ -55,4 +55,3 @@ function revive(obj: any, depth: number): any {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import types = require('vs/base/common/types');
|
||||
|
||||
export function clamp(value: number, min: number, max: number): number {
|
||||
@@ -18,6 +19,7 @@ export function rot(index: number, modulo: number): number {
|
||||
// {{SQL CARBON EDIT}}
|
||||
export type NumberCallback = (index: number) => void;
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
export function count(to: number, callback: NumberCallback): void;
|
||||
export function count(from: number, to: number, callback: NumberCallback): void;
|
||||
export function count(fromOrTo: number, toOrCallback?: NumberCallback | number, callback?: NumberCallback): any {
|
||||
|
||||
128
src/vs/base/common/octicon.ts
Normal file
128
src/vs/base/common/octicon.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { matchesFuzzy, IMatch } from 'vs/base/common/filters';
|
||||
import { ltrim } from 'vs/base/common/strings';
|
||||
|
||||
const octiconStartMarker = '$(';
|
||||
|
||||
export interface IParsedOcticons {
|
||||
text: string;
|
||||
octiconOffsets?: number[];
|
||||
}
|
||||
|
||||
export function parseOcticons(text: string): IParsedOcticons {
|
||||
const firstOcticonIndex = text.indexOf(octiconStartMarker);
|
||||
if (firstOcticonIndex === -1) {
|
||||
return { text }; // return early if the word does not include an octicon
|
||||
}
|
||||
|
||||
return doParseOcticons(text, firstOcticonIndex);
|
||||
}
|
||||
|
||||
function doParseOcticons(text: string, firstOcticonIndex: number): IParsedOcticons {
|
||||
const octiconOffsets: number[] = [];
|
||||
let textWithoutOcticons: string = '';
|
||||
|
||||
function appendChars(chars: string) {
|
||||
if (chars) {
|
||||
textWithoutOcticons += chars;
|
||||
|
||||
for (let i = 0; i < chars.length; i++) {
|
||||
octiconOffsets.push(octiconsOffset); // make sure to fill in octicon offsets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let currentOcticonStart = -1;
|
||||
let currentOcticonValue: string = '';
|
||||
let octiconsOffset = 0;
|
||||
|
||||
let char: string;
|
||||
let nextChar: string;
|
||||
|
||||
let offset = firstOcticonIndex;
|
||||
const length = text.length;
|
||||
|
||||
// Append all characters until the first octicon
|
||||
appendChars(text.substr(0, firstOcticonIndex));
|
||||
|
||||
// example: $(file-symlink-file) my cool $(other-octicon) entry
|
||||
while (offset < length) {
|
||||
char = text[offset];
|
||||
nextChar = text[offset + 1];
|
||||
|
||||
// beginning of octicon: some value $( <--
|
||||
if (char === octiconStartMarker[0] && nextChar === octiconStartMarker[1]) {
|
||||
currentOcticonStart = offset;
|
||||
|
||||
// if we had a previous potential octicon value without
|
||||
// the closing ')', it was actually not an octicon and
|
||||
// so we have to add it to the actual value
|
||||
appendChars(currentOcticonValue);
|
||||
|
||||
currentOcticonValue = octiconStartMarker;
|
||||
|
||||
offset++; // jump over '('
|
||||
}
|
||||
|
||||
// end of octicon: some value $(some-octicon) <--
|
||||
else if (char === ')' && currentOcticonStart !== -1) {
|
||||
const currentOcticonLength = offset - currentOcticonStart + 1; // +1 to include the closing ')'
|
||||
octiconsOffset += currentOcticonLength;
|
||||
currentOcticonStart = -1;
|
||||
currentOcticonValue = '';
|
||||
}
|
||||
|
||||
// within octicon
|
||||
else if (currentOcticonStart !== -1) {
|
||||
currentOcticonValue += char;
|
||||
}
|
||||
|
||||
// any value outside of octicons
|
||||
else {
|
||||
appendChars(char);
|
||||
}
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
||||
// if we had a previous potential octicon value without
|
||||
// the closing ')', it was actually not an octicon and
|
||||
// so we have to add it to the actual value
|
||||
appendChars(currentOcticonValue);
|
||||
|
||||
return { text: textWithoutOcticons, octiconOffsets };
|
||||
}
|
||||
|
||||
export function matchesFuzzyOcticonAware(query: string, target: IParsedOcticons, enableSeparateSubstringMatching = false): IMatch[] {
|
||||
const { text, octiconOffsets } = target;
|
||||
|
||||
// Return early if there are no octicon markers in the word to match against
|
||||
if (!octiconOffsets || octiconOffsets.length === 0) {
|
||||
return matchesFuzzy(query, text, enableSeparateSubstringMatching);
|
||||
}
|
||||
|
||||
// Trim the word to match against because it could have leading
|
||||
// whitespace now if the word started with an octicon
|
||||
const wordToMatchAgainstWithoutOcticonsTrimmed = ltrim(text, ' ');
|
||||
const leadingWhitespaceOffset = text.length - wordToMatchAgainstWithoutOcticonsTrimmed.length;
|
||||
|
||||
// match on value without octicons
|
||||
const matches = matchesFuzzy(query, wordToMatchAgainstWithoutOcticonsTrimmed, enableSeparateSubstringMatching);
|
||||
|
||||
// Map matches back to offsets with octicons and trimming
|
||||
if (matches) {
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
const octiconOffset = octiconOffsets[matches[i].start] /* octicon offsets at index */ + leadingWhitespaceOffset /* overall leading whitespace offset */;
|
||||
matches[i].start += octiconOffset;
|
||||
matches[i].end += octiconOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
6
src/vs/base/common/performance.d.ts
vendored
6
src/vs/base/common/performance.d.ts
vendored
@@ -11,7 +11,8 @@ export interface PerformanceEntry {
|
||||
}
|
||||
|
||||
export function mark(name: string): void;
|
||||
export function measure(name: string, from?: string, to?: string): void;
|
||||
|
||||
export function measure(name: string, from?: string, to?: string): PerformanceEntry;
|
||||
|
||||
/**
|
||||
* Time something, shorthant for `mark` and `measure`
|
||||
@@ -23,6 +24,9 @@ export function time(name: string): { stop(): void };
|
||||
*/
|
||||
export function getEntries(type: 'mark' | 'measure'): PerformanceEntry[];
|
||||
|
||||
export function getEntry(type: 'mark' | 'measure', name: string): PerformanceEntry;
|
||||
|
||||
export function getDuration(from: string, to: string): number;
|
||||
|
||||
type ExportData = any[];
|
||||
export function importEntries(data: ExportData): void;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// Because we want both instances to use the same perf-data
|
||||
// we store them globally
|
||||
// stores data as 'type','name','startTime','duration'
|
||||
global._performanceEntries = global._performanceEntries || [];
|
||||
|
||||
if (typeof define !== "function" && typeof module === "object" && typeof module.exports === "object") {
|
||||
// this is commonjs, fake amd
|
||||
@@ -23,6 +22,12 @@ if (typeof define !== "function" && typeof module === "object" && typeof module.
|
||||
|
||||
define([], function () {
|
||||
|
||||
var _global = this;
|
||||
if (typeof global !== 'undefined') {
|
||||
_global = global;
|
||||
}
|
||||
_global._performanceEntries = _global._performanceEntries || [];
|
||||
|
||||
// const _now = global.performance && performance.now ? performance.now : Date.now
|
||||
const _now = Date.now;
|
||||
|
||||
@@ -31,14 +36,14 @@ define([], function () {
|
||||
}
|
||||
|
||||
function exportEntries() {
|
||||
return global._performanceEntries.splice(0);
|
||||
return global._performanceEntries.slice(0);
|
||||
}
|
||||
|
||||
function getEntries(type) {
|
||||
function getEntries(type, name) {
|
||||
const result = [];
|
||||
const entries = global._performanceEntries;
|
||||
for (let i = 0; i < entries.length; i += 4) {
|
||||
if (entries[i] === type) {
|
||||
if (entries[i] === type && (name === void 0 || entries[i + 1] === name)) {
|
||||
result.push({
|
||||
type: entries[i],
|
||||
name: entries[i + 1],
|
||||
@@ -53,6 +58,39 @@ define([], function () {
|
||||
});
|
||||
}
|
||||
|
||||
function getEntry(type, name) {
|
||||
const entries = global._performanceEntries;
|
||||
for (let i = 0; i < entries.length; i += 4) {
|
||||
if (entries[i] === type && entries[i + 1] === name) {
|
||||
return {
|
||||
type: entries[i],
|
||||
name: entries[i + 1],
|
||||
startTime: entries[i + 2],
|
||||
duration: entries[i + 3],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getDuration(from, to) {
|
||||
const entries = global._performanceEntries;
|
||||
let name = from;
|
||||
let startTime = 0;
|
||||
for (let i = 0; i < entries.length; i += 4) {
|
||||
if (entries[i + 1] === name) {
|
||||
if (name === from) {
|
||||
// found `from` (start of interval)
|
||||
name = to;
|
||||
startTime = entries[i + 2];
|
||||
} else {
|
||||
// from `to` (end of interval)
|
||||
return entries[i + 2] - startTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function mark(name) {
|
||||
global._performanceEntries.push('mark', name, _now(), 0);
|
||||
if (typeof console.timeStamp === 'function') {
|
||||
@@ -103,6 +141,8 @@ define([], function () {
|
||||
measure: measure,
|
||||
time: time,
|
||||
getEntries: getEntries,
|
||||
getEntry: getEntry,
|
||||
getDuration: getDuration,
|
||||
importEntries: importEntries,
|
||||
exportEntries: exportEntries
|
||||
};
|
||||
|
||||
@@ -4,20 +4,19 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
// --- THIS FILE IS TEMPORARY UNTIL ENV.TS IS CLEANED UP. IT CAN SAFELY BE USED IN ALL TARGET EXECUTION ENVIRONMENTS (node & dom) ---
|
||||
|
||||
let _isWindows = false;
|
||||
let _isMacintosh = false;
|
||||
let _isLinux = false;
|
||||
let _isRootUser = false;
|
||||
let _isNative = false;
|
||||
let _isWeb = false;
|
||||
let _locale: string = undefined;
|
||||
let _language: string = undefined;
|
||||
let _translationsConfigFile: string = undefined;
|
||||
|
||||
interface NLSConfig {
|
||||
locale: string;
|
||||
availableLanguages: { [key: string]: string; };
|
||||
_translationsConfigFile: string;
|
||||
}
|
||||
|
||||
export interface IProcessEnvironment {
|
||||
@@ -28,6 +27,7 @@ interface INodeProcess {
|
||||
platform: string;
|
||||
env: IProcessEnvironment;
|
||||
getuid(): number;
|
||||
nextTick: Function;
|
||||
}
|
||||
declare let process: INodeProcess;
|
||||
declare let global: any;
|
||||
@@ -42,25 +42,25 @@ declare let self: any;
|
||||
export const LANGUAGE_DEFAULT = 'en';
|
||||
|
||||
// OS detection
|
||||
if (typeof process === 'object') {
|
||||
if (typeof process === 'object' && typeof process.nextTick === 'function') {
|
||||
_isWindows = (process.platform === 'win32');
|
||||
_isMacintosh = (process.platform === 'darwin');
|
||||
_isLinux = (process.platform === 'linux');
|
||||
_isRootUser = !_isWindows && (process.getuid() === 0);
|
||||
let rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
|
||||
const rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
|
||||
if (rawNlsConfig) {
|
||||
try {
|
||||
let nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
|
||||
let resolved = nlsConfig.availableLanguages['*'];
|
||||
const nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
|
||||
const resolved = nlsConfig.availableLanguages['*'];
|
||||
_locale = nlsConfig.locale;
|
||||
// VSCode's default language is 'en'
|
||||
_language = resolved ? resolved : LANGUAGE_DEFAULT;
|
||||
_translationsConfigFile = nlsConfig._translationsConfigFile;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
_isNative = true;
|
||||
} else if (typeof navigator === 'object') {
|
||||
let userAgent = navigator.userAgent;
|
||||
const userAgent = navigator.userAgent;
|
||||
_isWindows = userAgent.indexOf('Windows') >= 0;
|
||||
_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
|
||||
_isLinux = userAgent.indexOf('Linux') >= 0;
|
||||
@@ -90,11 +90,14 @@ if (_isNative) {
|
||||
export const isWindows = _isWindows;
|
||||
export const isMacintosh = _isMacintosh;
|
||||
export const isLinux = _isLinux;
|
||||
export const isRootUser = _isRootUser;
|
||||
export const isNative = _isNative;
|
||||
export const isWeb = _isWeb;
|
||||
export const platform = _platform;
|
||||
|
||||
export function isRootUser(): boolean {
|
||||
return _isNative && !_isWindows && (process.getuid() === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The language used for the user interface. The format of
|
||||
* the string is all lower case (e.g. zh-tw for Traditional
|
||||
@@ -109,30 +112,14 @@ export const language = _language;
|
||||
*/
|
||||
export const locale = _locale;
|
||||
|
||||
export interface TimeoutToken {
|
||||
}
|
||||
/**
|
||||
* The translatios that are available through language packs.
|
||||
*/
|
||||
export const translationsConfigFile = _translationsConfigFile;
|
||||
|
||||
export interface IntervalToken {
|
||||
}
|
||||
|
||||
interface IGlobals {
|
||||
Worker?: any;
|
||||
setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutToken;
|
||||
clearTimeout(token: TimeoutToken): void;
|
||||
|
||||
setInterval(callback: (...args: any[]) => void, delay: number, ...args: any[]): IntervalToken;
|
||||
clearInterval(token: IntervalToken): void;
|
||||
}
|
||||
|
||||
const _globals = <IGlobals>(typeof self === 'object' ? self : global);
|
||||
const _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {} as any);
|
||||
export const globals: any = _globals;
|
||||
|
||||
export const setTimeout = _globals.setTimeout.bind(_globals);
|
||||
export const clearTimeout = _globals.clearTimeout.bind(_globals);
|
||||
|
||||
export const setInterval = _globals.setInterval.bind(_globals);
|
||||
export const clearInterval = _globals.clearInterval.bind(_globals);
|
||||
|
||||
export const enum OperatingSystem {
|
||||
Windows = 1,
|
||||
Macintosh = 2,
|
||||
|
||||
@@ -12,9 +12,9 @@ export function basenameOrAuthority(resource: uri): string {
|
||||
return paths.basename(resource.fsPath) || resource.authority;
|
||||
}
|
||||
|
||||
export function isEqualOrParent(first: uri, second: uri, ignoreCase?: boolean): boolean {
|
||||
if (first.scheme === second.scheme && first.authority === second.authority) {
|
||||
return paths.isEqualOrParent(first.fsPath, second.fsPath, ignoreCase);
|
||||
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);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -38,7 +38,32 @@ export function isEqual(first: uri, second: uri, ignoreCase?: boolean): boolean
|
||||
}
|
||||
|
||||
export function dirname(resource: uri): uri {
|
||||
const dirname = paths.dirname(resource.path);
|
||||
if (resource.authority && dirname && !paths.isAbsolute(dirname)) {
|
||||
return null; // If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character
|
||||
}
|
||||
|
||||
return resource.with({
|
||||
path: paths.dirname(resource.path)
|
||||
path: dirname
|
||||
});
|
||||
}
|
||||
|
||||
export function distinctParents<T>(items: T[], resourceAccessor: (item: T) => uri): T[] {
|
||||
const distinctParents: T[] = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const candidateResource = resourceAccessor(items[i]);
|
||||
if (items.some((otherItem, index) => {
|
||||
if (index === i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isEqualOrParent(candidateResource, resourceAccessor(otherItem));
|
||||
})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
distinctParents.push(items[i]);
|
||||
}
|
||||
|
||||
return distinctParents;
|
||||
}
|
||||
@@ -712,3 +712,15 @@ export function fuzzyContains(target: string, query: string): boolean {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function containsUppercaseCharacter(target: string, ignoreEscapedChars = false): boolean {
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ignoreEscapedChars) {
|
||||
target = target.replace(/\\./g, '');
|
||||
}
|
||||
|
||||
return target.toLowerCase() !== target;
|
||||
}
|
||||
|
||||
@@ -174,27 +174,27 @@ export default class URI implements UriComponents {
|
||||
if (scheme === void 0) {
|
||||
scheme = this.scheme;
|
||||
} else if (scheme === null) {
|
||||
scheme = '';
|
||||
scheme = _empty;
|
||||
}
|
||||
if (authority === void 0) {
|
||||
authority = this.authority;
|
||||
} else if (authority === null) {
|
||||
authority = '';
|
||||
authority = _empty;
|
||||
}
|
||||
if (path === void 0) {
|
||||
path = this.path;
|
||||
} else if (path === null) {
|
||||
path = '';
|
||||
path = _empty;
|
||||
}
|
||||
if (query === void 0) {
|
||||
query = this.query;
|
||||
} else if (query === null) {
|
||||
query = '';
|
||||
query = _empty;
|
||||
}
|
||||
if (fragment === void 0) {
|
||||
fragment = this.fragment;
|
||||
} else if (fragment === null) {
|
||||
fragment = '';
|
||||
fragment = _empty;
|
||||
}
|
||||
|
||||
if (scheme === this.scheme
|
||||
@@ -315,10 +315,16 @@ export default class URI implements UriComponents {
|
||||
}
|
||||
|
||||
static revive(data: UriComponents | any): URI {
|
||||
let result = new _URI(data);
|
||||
result._fsPath = (<UriState>data).fsPath;
|
||||
result._formatted = (<UriState>data).external;
|
||||
return result;
|
||||
if (!data) {
|
||||
return data;
|
||||
} else if (data instanceof URI) {
|
||||
return data;
|
||||
} else {
|
||||
let result = new _URI(data);
|
||||
result._fsPath = (<UriState>data).fsPath;
|
||||
result._formatted = (<UriState>data).external;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
(function() {
|
||||
|
||||
var _modules = {};
|
||||
var _modules = Object.create(null);//{};
|
||||
_modules["WinJS/Core/_WinJS"] = {};
|
||||
|
||||
var _winjs = function(moduleId, deps, factory) {
|
||||
@@ -64,11 +64,24 @@ _winjs("WinJS/Core/_BaseCoreUtils", ["WinJS/Core/_Global"], function baseCoreUti
|
||||
return func;
|
||||
}
|
||||
|
||||
var actualSetImmediate = null;
|
||||
|
||||
return {
|
||||
hasWinRT: hasWinRT,
|
||||
markSupportedForProcessing: markSupportedForProcessing,
|
||||
_setImmediate: _Global.setImmediate ? _Global.setImmediate.bind(_Global) : function (handler) {
|
||||
_Global.setTimeout(handler, 0);
|
||||
_setImmediate: function (callback) {
|
||||
// BEGIN monaco change
|
||||
if (actualSetImmediate === null) {
|
||||
if (_Global.setImmediate) {
|
||||
actualSetImmediate = _Global.setImmediate.bind(_Global);
|
||||
} else if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
|
||||
actualSetImmediate = process.nextTick.bind(process);
|
||||
} else {
|
||||
actualSetImmediate = _Global.setTimeout.bind(_Global);
|
||||
}
|
||||
}
|
||||
actualSetImmediate(callback);
|
||||
// END monaco change
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -2057,15 +2070,9 @@ _winjs("WinJS/Promise", ["WinJS/Core/_Base","WinJS/Promise/_StateMachine"], func
|
||||
var exported = _modules["WinJS/Core/_WinJS"];
|
||||
|
||||
if (typeof exports === 'undefined' && typeof define === 'function' && define.amd) {
|
||||
define(exported);
|
||||
define([], exported);
|
||||
} else {
|
||||
module.exports = exported;
|
||||
}
|
||||
|
||||
if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
|
||||
_modules["WinJS/Core/_BaseCoreUtils"]._setImmediate = function(handler) {
|
||||
return process.nextTick(handler);
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
@@ -163,6 +163,10 @@ class SimpleWorkerProtocol {
|
||||
err: undefined
|
||||
});
|
||||
}, (e) => {
|
||||
if (e.detail instanceof Error) {
|
||||
// Loading errors have a detail property that points to the actual error
|
||||
e.detail = transformErrorForSerialization(e.detail);
|
||||
}
|
||||
this._send({
|
||||
vsWorker: this._workerId,
|
||||
seq: req,
|
||||
@@ -339,13 +343,6 @@ export class SimpleWorkerServer {
|
||||
delete loaderConfig.paths['vs'];
|
||||
}
|
||||
}
|
||||
let nlsConfig = loaderConfig['vs/nls'];
|
||||
// We need to have pseudo translation
|
||||
if (nlsConfig && nlsConfig.pseudo) {
|
||||
require(['vs/nls'], function (nlsPlugin) {
|
||||
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
|
||||
});
|
||||
}
|
||||
|
||||
// Since this is in a web worker, enable catching errors
|
||||
loaderConfig.catchError = true;
|
||||
|
||||
Reference in New Issue
Block a user