Merge from vscode 93309f060778f6480a7d2a13913e6e7c624e9bc7

This commit is contained in:
ADS Merger
2020-03-26 07:08:23 +00:00
parent 685e0ccf7e
commit f5134198e2
87 changed files with 942 additions and 631 deletions

View File

@@ -5,7 +5,7 @@
@font-face {
font-family: "codicon";
src: url("./codicon.ttf?3d9ee7d873425ff0bc441f48a1de0c54") format("truetype");
src: url("./codicon.ttf?70edf2c63384951357ed8517386759dd") format("truetype");
}
.codicon[class*='codicon-'] {

View File

@@ -21,6 +21,7 @@ import { asArray } from 'vs/base/common/arrays';
import { ScanCodeUtils, ScanCode } from 'vs/base/common/scanCode';
import { isMacintosh } from 'vs/base/common/platform';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
const $ = DOM.$;
@@ -90,7 +91,7 @@ export class MenuBar extends Disposable {
private menuStyle: IMenuStyles | undefined;
private overflowLayoutScheduled: IDisposable | undefined = undefined;
constructor(private container: HTMLElement, private options: IMenuBarOptions = {}) {
constructor(private container: HTMLElement, private options: IMenuBarOptions = {}, private compactMenuActions?: IAction[]) {
super();
this.container.setAttribute('role', 'menubar');
@@ -490,6 +491,11 @@ export class MenuBar extends Disposable {
this.container.insertBefore(this.overflowMenu.buttonElement, this.menuCache[this.numMenusShown].buttonElement);
this.overflowMenu.buttonElement.style.visibility = 'visible';
}
if (this.compactMenuActions && this.compactMenuActions.length) {
this.overflowMenu.actions.push(new Separator());
this.overflowMenu.actions.push(...this.compactMenuActions);
}
} else {
DOM.removeNode(this.overflowMenu.buttonElement);
this.container.appendChild(this.overflowMenu.buttonElement);

View File

@@ -74,26 +74,24 @@ export class Storage extends Disposable implements IStorage {
private static readonly DEFAULT_FLUSH_DELAY = 100;
private readonly _onDidChangeStorage: Emitter<string> = this._register(new Emitter<string>());
readonly onDidChangeStorage: Event<string> = this._onDidChangeStorage.event;
private readonly _onDidChangeStorage = this._register(new Emitter<string>());
readonly onDidChangeStorage = this._onDidChangeStorage.event;
private state = StorageState.None;
private cache: Map<string, string> = new Map<string, string>();
private cache = new Map<string, string>();
private flushDelayer: ThrottledDelayer<void>;
private readonly flushDelayer = this._register(new ThrottledDelayer<void>(Storage.DEFAULT_FLUSH_DELAY));
private pendingDeletes: Set<string> = new Set<string>();
private pendingInserts: Map<string, string> = new Map();
private pendingDeletes = new Set<string>();
private pendingInserts = new Map<string, string>();
constructor(
protected database: IStorageDatabase,
private options: IStorageOptions = Object.create(null)
protected readonly database: IStorageDatabase,
private readonly options: IStorageOptions = Object.create(null)
) {
super();
this.flushDelayer = this._register(new ThrottledDelayer(Storage.DEFAULT_FLUSH_DELAY));
this.registerListeners();
}
@@ -146,7 +144,7 @@ export class Storage extends Disposable implements IStorage {
async init(): Promise<void> {
if (this.state !== StorageState.None) {
return Promise.resolve(); // either closed or already initialized
return; // either closed or already initialized
}
this.state = StorageState.Initialized;
@@ -155,7 +153,7 @@ export class Storage extends Disposable implements IStorage {
// return early if we know the storage file does not exist. this is a performance
// optimization to not load all items of the underlying storage if we know that
// there can be no items because the storage does not exist.
return Promise.resolve();
return;
}
this.cache = await this.database.getItems();
@@ -296,13 +294,13 @@ export class InMemoryStorageDatabase implements IStorageDatabase {
readonly onDidChangeItemsExternal = Event.None;
private items = new Map<string, string>();
private readonly items = new Map<string, string>();
getItems(): Promise<Map<string, string>> {
return Promise.resolve(this.items);
async getItems(): Promise<Map<string, string>> {
return this.items;
}
updateItems(request: IUpdateRequest): Promise<void> {
async updateItems(request: IUpdateRequest): Promise<void> {
if (request.insert) {
request.insert.forEach((value, key) => this.items.set(key, value));
}
@@ -310,11 +308,7 @@ export class InMemoryStorageDatabase implements IStorageDatabase {
if (request.delete) {
request.delete.forEach(key => this.items.delete(key));
}
return Promise.resolve();
}
close(): Promise<void> {
return Promise.resolve();
}
async close(): Promise<void> { }
}

View File

@@ -13,9 +13,9 @@ import { fill } from 'vs/base/common/arrays';
import { IStorageDatabase, IStorageItemsChangeEvent, IUpdateRequest } from 'vs/base/parts/storage/common/storage';
interface IDatabaseConnection {
db: Database;
readonly db: Database;
isInMemory: boolean;
readonly isInMemory: boolean;
isErroneous?: boolean;
lastError?: string;
@@ -39,21 +39,13 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
private static readonly BUSY_OPEN_TIMEOUT = 2000; // timeout in ms to retry when opening DB fails with SQLITE_BUSY
private static readonly MAX_HOST_PARAMETERS = 256; // maximum number of parameters within a statement
private path: string;
private name: string;
private readonly name = basename(this.path);
private logger: SQLiteStorageDatabaseLogger;
private readonly logger = new SQLiteStorageDatabaseLogger(this.options.logging);
private whenConnected: Promise<IDatabaseConnection>;
private readonly whenConnected = this.connect(this.path);
constructor(path: string, options: ISQLiteStorageDatabaseOptions = Object.create(null)) {
this.path = path;
this.name = basename(path);
this.logger = new SQLiteStorageDatabaseLogger(options.logging);
this.whenConnected = this.connect(path);
}
constructor(private path: string, private options: ISQLiteStorageDatabaseOptions = Object.create(null)) { }
async getItems(): Promise<Map<string, string>> {
const connection = await this.whenConnected;
@@ -166,7 +158,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
return new Promise((resolve, reject) => {
connection.db.close(closeError => {
if (closeError) {
this.handleSQLiteError(connection, closeError, `[storage ${this.name}] close(): ${closeError}`);
this.handleSQLiteError(connection, `[storage ${this.name}] close(): ${closeError}`);
}
// Return early if this storage was created only in-memory
@@ -296,7 +288,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
}
}
private handleSQLiteError(connection: IDatabaseConnection, error: Error & { code?: string }, msg: string): void {
private handleSQLiteError(connection: IDatabaseConnection, msg: string): void {
connection.isErroneous = true;
connection.lastError = msg;
@@ -328,7 +320,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
};
// Errors
connection.db.on('error', error => this.handleSQLiteError(connection, error, `[storage ${this.name}] Error (event): ${error}`));
connection.db.on('error', error => this.handleSQLiteError(connection, `[storage ${this.name}] Error (event): ${error}`));
// Tracing
if (this.logger.isTracing) {
@@ -342,7 +334,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
return new Promise((resolve, reject) => {
connection.db.exec(sql, error => {
if (error) {
this.handleSQLiteError(connection, error, `[storage ${this.name}] exec(): ${error}`);
this.handleSQLiteError(connection, `[storage ${this.name}] exec(): ${error}`);
return reject(error);
}
@@ -356,7 +348,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
return new Promise((resolve, reject) => {
connection.db.get(sql, (error, row) => {
if (error) {
this.handleSQLiteError(connection, error, `[storage ${this.name}] get(): ${error}`);
this.handleSQLiteError(connection, `[storage ${this.name}] get(): ${error}`);
return reject(error);
}
@@ -370,7 +362,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
return new Promise((resolve, reject) => {
connection.db.all(sql, (error, rows) => {
if (error) {
this.handleSQLiteError(connection, error, `[storage ${this.name}] all(): ${error}`);
this.handleSQLiteError(connection, `[storage ${this.name}] all(): ${error}`);
return reject(error);
}
@@ -389,7 +381,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
connection.db.run('END TRANSACTION', error => {
if (error) {
this.handleSQLiteError(connection, error, `[storage ${this.name}] transaction(): ${error}`);
this.handleSQLiteError(connection, `[storage ${this.name}] transaction(): ${error}`);
return reject(error);
}
@@ -404,7 +396,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
const stmt = connection.db.prepare(sql);
const statementErrorListener = (error: Error) => {
this.handleSQLiteError(connection, error, `[storage ${this.name}] prepare(): ${error} (${sql}). Details: ${errorDetails()}`);
this.handleSQLiteError(connection, `[storage ${this.name}] prepare(): ${error} (${sql}). Details: ${errorDetails()}`);
};
stmt.on('error', statementErrorListener);

View File

@@ -538,7 +538,7 @@ suite('URI', () => {
assert.throws(() => assertJoined(('foo:'), 'bazz', ''));
assert.throws(() => new URL('bazz', 'foo:'));
assert.throws(() => assertJoined(('foo://bar'), 'bazz', ''));
assert.throws(() => new URL('bazz', 'foo://bar'));
// assert.throws(() => new URL('bazz', 'foo://bar')); Edge,Chrome => throw, Safari => foo://bar/bazz, Firefox ??
});
test('URI#joinPath (posix)', function () {