mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 17:23:42 -05:00
Merge from vscode e558dc6ea73a75bd69d7a0b485f0e7e4194c66bf (#6864)
This commit is contained in:
@@ -10,6 +10,7 @@ import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview
|
||||
import { IHistoryNavigationWidget } from 'vs/base/browser/history';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ReplaceInput, IReplaceInputOptions } from 'vs/base/browser/ui/findinput/replaceInput';
|
||||
|
||||
export const HistoryNavigationWidgetContext = 'historyNavigationWidget';
|
||||
export const HistoryNavigationEnablementContext = 'historyNavigationEnabled';
|
||||
@@ -60,6 +61,16 @@ export class ContextScopedFindInput extends FindInput {
|
||||
super(container, contextViewProvider, showFindOptions, options);
|
||||
this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.inputBox.element, historyNavigator: this.inputBox }).scopedContextKeyService);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextScopedReplaceInput extends ReplaceInput {
|
||||
|
||||
constructor(container: HTMLElement | null, contextViewProvider: IContextViewProvider | undefined, options: IReplaceInputOptions,
|
||||
@IContextKeyService contextKeyService: IContextKeyService, showReplaceOptions: boolean = false
|
||||
) {
|
||||
super(container, contextViewProvider, showReplaceOptions, options);
|
||||
this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.inputBox.element, historyNavigator: this.inputBox }).scopedContextKeyService);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -76,16 +76,27 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
|
||||
return done(results);
|
||||
}
|
||||
|
||||
if (token.count > MAX_FILES) {
|
||||
token.count += files.length;
|
||||
token.maxReached = true;
|
||||
return done(results);
|
||||
}
|
||||
|
||||
let pending = files.length;
|
||||
if (pending === 0) {
|
||||
return done(results);
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
if (token.maxReached) {
|
||||
return done(results);
|
||||
}
|
||||
let filesToRead = files;
|
||||
if (token.count + files.length > MAX_FILES) {
|
||||
token.maxReached = true;
|
||||
pending = MAX_FILES - token.count;
|
||||
filesToRead = files.slice(0, pending);
|
||||
}
|
||||
|
||||
token.count += files.length;
|
||||
|
||||
for (const file of filesToRead) {
|
||||
stat(join(dir, file), (err, stats) => {
|
||||
// Ignore files that can't be read
|
||||
if (err) {
|
||||
@@ -108,11 +119,6 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (token.count >= MAX_FILES) {
|
||||
token.maxReached = true;
|
||||
}
|
||||
|
||||
token.count++;
|
||||
results.push(file);
|
||||
|
||||
if (--pending === 0) {
|
||||
|
||||
134
src/vs/platform/log/common/fileLogService.ts
Normal file
134
src/vs/platform/log/common/fileLogService.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ILogService, LogLevel, AbstractLogService } from 'vs/platform/log/common/log';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { Queue } from 'vs/base/common/async';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
|
||||
export class FileLogService extends AbstractLogService implements ILogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly queue: Queue<void>;
|
||||
|
||||
constructor(
|
||||
private readonly name: string,
|
||||
private readonly resource: URI,
|
||||
level: LogLevel,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
) {
|
||||
super();
|
||||
this.setLevel(level);
|
||||
this.queue = this._register(new Queue<void>());
|
||||
}
|
||||
|
||||
trace(): void {
|
||||
if (this.getLevel() <= LogLevel.Trace) {
|
||||
this._log(LogLevel.Trace, this.format(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
debug(): void {
|
||||
if (this.getLevel() <= LogLevel.Debug) {
|
||||
this._log(LogLevel.Debug, this.format(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
info(): void {
|
||||
if (this.getLevel() <= LogLevel.Info) {
|
||||
this._log(LogLevel.Info, this.format(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
warn(): void {
|
||||
if (this.getLevel() <= LogLevel.Warning) {
|
||||
this._log(LogLevel.Warning, this.format(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
error(): void {
|
||||
if (this.getLevel() <= LogLevel.Error) {
|
||||
const arg = arguments[0];
|
||||
|
||||
if (arg instanceof Error) {
|
||||
const array = Array.prototype.slice.call(arguments) as any[];
|
||||
array[0] = arg.stack;
|
||||
this._log(LogLevel.Error, this.format(array));
|
||||
} else {
|
||||
this._log(LogLevel.Error, this.format(arguments));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
critical(): void {
|
||||
if (this.getLevel() <= LogLevel.Critical) {
|
||||
this._log(LogLevel.Critical, this.format(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
flush(): Promise<void> {
|
||||
return this.queue.queue(() => Promise.resolve());
|
||||
}
|
||||
|
||||
log(level: LogLevel, args: any[]): void {
|
||||
this._log(level, this.format(args));
|
||||
}
|
||||
|
||||
private _log(level: LogLevel, message: string): void {
|
||||
this.queue.queue(async () => {
|
||||
let content = await this.loadContent();
|
||||
content += `[${this.getCurrentTimestamp()}] [${this.name}] [${this.stringifyLogLevel(level)}] ${message}\n`;
|
||||
await this.fileService.writeFile(this.resource, VSBuffer.fromString(content));
|
||||
});
|
||||
}
|
||||
|
||||
private getCurrentTimestamp(): string {
|
||||
const toTwoDigits = (v: number) => v < 10 ? `0${v}` : v;
|
||||
const toThreeDigits = (v: number) => v < 10 ? `00${v}` : v < 100 ? `0${v}` : v;
|
||||
const currentTime = new Date();
|
||||
return `${currentTime.getFullYear()}-${toTwoDigits(currentTime.getMonth() + 1)}-${toTwoDigits(currentTime.getDate())} ${toTwoDigits(currentTime.getHours())}:${toTwoDigits(currentTime.getMinutes())}:${toTwoDigits(currentTime.getSeconds())}.${toThreeDigits(currentTime.getMilliseconds())}`;
|
||||
}
|
||||
|
||||
private async loadContent(): Promise<string> {
|
||||
try {
|
||||
const content = await this.fileService.readFile(this.resource);
|
||||
return content.value.toString();
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
private stringifyLogLevel(level: LogLevel): string {
|
||||
switch (level) {
|
||||
case LogLevel.Critical: return 'critical';
|
||||
case LogLevel.Debug: return 'debug';
|
||||
case LogLevel.Error: return 'error';
|
||||
case LogLevel.Info: return 'info';
|
||||
case LogLevel.Trace: return 'trace';
|
||||
case LogLevel.Warning: return 'warning';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private format(args: any): string {
|
||||
let result = '';
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
let a = args[i];
|
||||
|
||||
if (typeof a === 'object') {
|
||||
try {
|
||||
a = JSON.stringify(a);
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
result += (i > 0 ? ' ' : '') + a;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ export interface IOpener {
|
||||
open(resource: URI, options?: { openExternal?: boolean }): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface IValidator {
|
||||
shouldOpen(resource: URI): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface IOpenerService {
|
||||
|
||||
_serviceBrand: any;
|
||||
@@ -23,6 +27,12 @@ export interface IOpenerService {
|
||||
*/
|
||||
registerOpener(opener: IOpener): IDisposable;
|
||||
|
||||
/**
|
||||
* Register a participant that can validate if the URI resource be opened.
|
||||
* validators are run before openers.
|
||||
*/
|
||||
registerValidator(validator: IValidator): IDisposable;
|
||||
|
||||
/**
|
||||
* Opens a resource, like a webaddress, a document uri, or executes command.
|
||||
*
|
||||
@@ -36,5 +46,6 @@ export interface IOpenerService {
|
||||
export const NullOpenerService: IOpenerService = Object.freeze({
|
||||
_serviceBrand: undefined,
|
||||
registerOpener() { return { dispose() { } }; },
|
||||
registerValidator() { return { dispose() { } }; },
|
||||
open() { return Promise.resolve(false); },
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ResolvedAuthority, IRemoteAuthorityResolverService, ResolverResult } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { RemoteAuthorities } from 'vs/base/common/network';
|
||||
|
||||
export class RemoteAuthorityResolverService implements IRemoteAuthorityResolverService {
|
||||
|
||||
@@ -15,13 +16,14 @@ export class RemoteAuthorityResolverService implements IRemoteAuthorityResolverS
|
||||
resolveAuthority(authority: string): Promise<ResolverResult> {
|
||||
if (authority.indexOf(':') >= 0) {
|
||||
const pieces = authority.split(':');
|
||||
return Promise.resolve({
|
||||
authority: { authority, host: pieces[0], port: parseInt(pieces[1], 10) }
|
||||
});
|
||||
return Promise.resolve(this._createResolvedAuthority(authority, pieces[0], parseInt(pieces[1], 10)));
|
||||
}
|
||||
return Promise.resolve({
|
||||
authority: { authority, host: authority, port: 80 }
|
||||
});
|
||||
return Promise.resolve(this._createResolvedAuthority(authority, authority, 80));
|
||||
}
|
||||
|
||||
private _createResolvedAuthority(authority: string, host: string, port: number): ResolverResult {
|
||||
RemoteAuthorities.set(authority, host, port);
|
||||
return { authority: { authority, host, port } };
|
||||
}
|
||||
|
||||
clearResolvedAuthority(authority: string): void {
|
||||
|
||||
Reference in New Issue
Block a user