mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Merge with master
This commit is contained in:
@@ -92,7 +92,7 @@ export function createApiFactory(
|
||||
extHostStorage: ExtHostStorage
|
||||
): IExtensionApiFactory {
|
||||
|
||||
let schemeTransformer: ISchemeTransformer | null = null;
|
||||
const schemeTransformer: ISchemeTransformer | null = null;
|
||||
|
||||
// Addressable instances
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLogService, extHostLogService);
|
||||
@@ -188,7 +188,7 @@ export function createApiFactory(
|
||||
},
|
||||
registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => void, thisArg?: any): vscode.Disposable {
|
||||
return extHostCommands.registerCommand(true, id, (...args: any[]): any => {
|
||||
let activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
const activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
if (!activeTextEditor) {
|
||||
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
|
||||
return undefined;
|
||||
@@ -209,7 +209,7 @@ export function createApiFactory(
|
||||
},
|
||||
registerDiffInformationCommand: proposedApiFunction(extension, (id: string, callback: (diff: vscode.LineChange[], ...args: any[]) => any, thisArg?: any): vscode.Disposable => {
|
||||
return extHostCommands.registerCommand(true, id, async (...args: any[]): Promise<any> => {
|
||||
let activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
const activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
if (!activeTextEditor) {
|
||||
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
|
||||
return undefined;
|
||||
@@ -566,7 +566,7 @@ export function createApiFactory(
|
||||
openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; content?: string; }) {
|
||||
let uriPromise: Thenable<URI>;
|
||||
|
||||
let options = uriOrFileNameOrOptions as { language?: string; content?: string; };
|
||||
const options = uriOrFileNameOrOptions as { language?: string; content?: string; };
|
||||
if (typeof uriOrFileNameOrOptions === 'string') {
|
||||
uriPromise = Promise.resolve(URI.file(uriOrFileNameOrOptions));
|
||||
} else if (uriOrFileNameOrOptions instanceof URI) {
|
||||
|
||||
@@ -142,7 +142,7 @@ export interface MainThreadConfigurationShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadDiagnosticsShape extends IDisposable {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void;
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[] | undefined][]): void;
|
||||
$clear(owner: string): void;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ export interface MainThreadProgressShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadTerminalServiceShape extends IDisposable {
|
||||
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | URI, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }>;
|
||||
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | UriComponents, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }>;
|
||||
$createTerminalRenderer(name: string): Promise<number>;
|
||||
$dispose(terminalId: number): void;
|
||||
$hide(terminalId: number): void;
|
||||
@@ -461,7 +461,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
|
||||
$show(instance: number, options: IPickOptions<TransferQuickPickItems>, token: CancellationToken): Promise<number | number[] | undefined>;
|
||||
$setItems(instance: number, items: TransferQuickPickItems[]): Promise<void>;
|
||||
$setError(instance: number, error: Error): Promise<void>;
|
||||
$input(options: vscode.InputBoxOptions, validateInput: boolean, token: CancellationToken): Promise<string>;
|
||||
$input(options: vscode.InputBoxOptions | undefined, validateInput: boolean, token: CancellationToken): Promise<string>;
|
||||
$createOrUpdate(params: TransferQuickInput): Promise<void>;
|
||||
$dispose(id: number): Promise<void>;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ export interface ExtHostUrlsShape {
|
||||
}
|
||||
|
||||
export interface MainThreadWorkspaceShape extends IDisposable {
|
||||
$startFileSearch(includePattern: string | undefined, includeFolder: URI | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<UriComponents[] | undefined>;
|
||||
$startFileSearch(includePattern: string | undefined, includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false | undefined, maxResults: number, token: CancellationToken): Promise<UriComponents[] | undefined>;
|
||||
$startTextSearch(query: IPatternInfo, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<vscode.TextSearchComplete>;
|
||||
$checkExists(includes: string[], token: CancellationToken): Promise<boolean>;
|
||||
$saveAll(includeUntitled?: boolean): Promise<boolean>;
|
||||
@@ -585,7 +585,7 @@ export interface SCMProviderFeatures {
|
||||
count?: number;
|
||||
commitTemplate?: string;
|
||||
acceptInputCommand?: modes.Command;
|
||||
statusBarCommands?: modes.Command[];
|
||||
statusBarCommands?: CommandDto[];
|
||||
}
|
||||
|
||||
export interface SCMGroupFeatures {
|
||||
@@ -863,9 +863,9 @@ export interface WorkspaceSymbolsDto extends IdObject {
|
||||
}
|
||||
|
||||
export interface ResourceFileEditDto {
|
||||
oldUri: UriComponents;
|
||||
newUri: UriComponents;
|
||||
options: IFileOperationOptions;
|
||||
oldUri?: UriComponents;
|
||||
newUri?: UriComponents;
|
||||
options?: IFileOperationOptions;
|
||||
}
|
||||
|
||||
export interface ResourceTextEditDto {
|
||||
@@ -968,7 +968,7 @@ export interface ShellLaunchConfigDto {
|
||||
name?: string;
|
||||
executable?: string;
|
||||
args?: string[] | string;
|
||||
cwd?: string | URI;
|
||||
cwd?: string | UriComponents;
|
||||
env?: { [key: string]: string | null };
|
||||
}
|
||||
|
||||
@@ -981,7 +981,7 @@ export interface ExtHostTerminalServiceShape {
|
||||
$acceptTerminalRendererInput(id: number, data: string): void;
|
||||
$acceptTerminalTitleChange(id: number, name: string): void;
|
||||
$acceptTerminalDimensions(id: number, cols: number, rows: number): void;
|
||||
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUri: URI, cols: number, rows: number): void;
|
||||
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUri: UriComponents, cols: number, rows: number): void;
|
||||
$acceptProcessInput(id: number, data: string): void;
|
||||
$acceptProcessResize(id: number, cols: number, rows: number): void;
|
||||
$acceptProcessShutdown(id: number, immediate: boolean): void;
|
||||
|
||||
@@ -263,7 +263,7 @@ export class ExtHostApiCommands {
|
||||
// --- command impl
|
||||
|
||||
private _register(id: string, handler: (...args: any[]) => any, description?: ICommandHandlerDescription): void {
|
||||
let disposable = this._commands.registerCommand(false, id, handler, this, description);
|
||||
const disposable = this._commands.registerCommand(false, id, handler, this, description);
|
||||
this._disposables.push(disposable);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ export class ExtHostApiCommands {
|
||||
}
|
||||
|
||||
private _executeSelectionRangeProvider(resource: URI, positions: types.Position[]): Promise<vscode.SelectionRange[][]> {
|
||||
let pos = positions.map(typeConverters.Position.from);
|
||||
const pos = positions.map(typeConverters.Position.from);
|
||||
const args = {
|
||||
resource,
|
||||
position: pos[0],
|
||||
@@ -443,7 +443,7 @@ export class ExtHostApiCommands {
|
||||
}
|
||||
class MergedInfo extends types.SymbolInformation implements vscode.DocumentSymbol {
|
||||
static to(symbol: modes.DocumentSymbol): MergedInfo {
|
||||
let res = new MergedInfo(
|
||||
const res = new MergedInfo(
|
||||
symbol.name,
|
||||
typeConverters.SymbolKind.to(symbol.kind),
|
||||
symbol.containerName,
|
||||
|
||||
@@ -39,7 +39,7 @@ export class CLIServer {
|
||||
console.error('Could not start open from terminal server.');
|
||||
}
|
||||
|
||||
return this.ipcHandlePath;
|
||||
return this._ipcHandlePath;
|
||||
}
|
||||
private collectURIToOpen(strs: string[], typeHint: URIType, result: IURIToOpen[]): void {
|
||||
if (Array.isArray(strs)) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
interface CommandHandler {
|
||||
callback: Function;
|
||||
thisArg: any;
|
||||
description: ICommandHandlerDescription;
|
||||
description?: ICommandHandlerDescription;
|
||||
}
|
||||
|
||||
export interface ArgumentProcessor {
|
||||
@@ -154,7 +154,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
|
||||
}
|
||||
|
||||
try {
|
||||
let result = callback.apply(thisArg, args);
|
||||
const result = callback.apply(thisArg, args);
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
this._logService.error(err, id);
|
||||
|
||||
@@ -344,7 +344,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
}
|
||||
|
||||
getComment(commentId: string): vscode.Comment | undefined {
|
||||
let comments = this._comments.filter(comment => comment.commentId === commentId);
|
||||
const comments = this._comments.filter(comment => comment.commentId === commentId);
|
||||
|
||||
if (comments && comments.length) {
|
||||
return comments[0];
|
||||
@@ -480,7 +480,7 @@ class ExtHostCommentControl implements vscode.CommentControl {
|
||||
}
|
||||
|
||||
$onActiveCommentWidgetChange(commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string) {
|
||||
let extHostCommentThread = this._threads.get(commentThread.commentThreadHandle);
|
||||
const extHostCommentThread = this._threads.get(commentThread.commentThreadHandle);
|
||||
|
||||
const extHostCommentWidget = new ExtHostCommentWidget(
|
||||
this._proxy,
|
||||
|
||||
@@ -255,7 +255,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
console.error('DebugConfigurationProvider.debugAdapterExecutable is deprecated and will be removed soon; please use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead.');
|
||||
}
|
||||
|
||||
let handle = this._configProviderHandleCounter++;
|
||||
const handle = this._configProviderHandleCounter++;
|
||||
this._configProviders.push({ type, handle, provider });
|
||||
|
||||
this._debugServiceProxy.$registerDebugConfigurationProvider(type,
|
||||
@@ -286,7 +286,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
throw new Error(`a DebugAdapterDescriptorFactory can only be registered once per a type.`);
|
||||
}
|
||||
|
||||
let handle = this._adapterFactoryHandleCounter++;
|
||||
const handle = this._adapterFactoryHandleCounter++;
|
||||
this._adapterFactories.push({ type, handle, factory });
|
||||
|
||||
this._debugServiceProxy.$registerDebugAdapterDescriptorFactory(type, handle);
|
||||
@@ -303,7 +303,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
return new Disposable(() => { });
|
||||
}
|
||||
|
||||
let handle = this._trackerFactoryHandleCounter++;
|
||||
const handle = this._trackerFactoryHandleCounter++;
|
||||
this._trackerFactories.push({ type, handle, factory });
|
||||
|
||||
this._debugServiceProxy.$registerDebugAdapterTrackerFactory(type, handle);
|
||||
@@ -494,9 +494,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
public $acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void {
|
||||
|
||||
let a: vscode.Breakpoint[] = [];
|
||||
let r: vscode.Breakpoint[] = [];
|
||||
let c: vscode.Breakpoint[] = [];
|
||||
const a: vscode.Breakpoint[] = [];
|
||||
const r: vscode.Breakpoint[] = [];
|
||||
const c: vscode.Breakpoint[] = [];
|
||||
|
||||
if (delta.added) {
|
||||
for (const bpd of delta.added) {
|
||||
@@ -528,7 +528,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
if (delta.changed) {
|
||||
for (const bpd of delta.changed) {
|
||||
let bp = this._breakpoints.get(bpd.id);
|
||||
const bp = this._breakpoints.get(bpd.id);
|
||||
if (bp) {
|
||||
if (bp instanceof FunctionBreakpoint && bpd.type === 'function') {
|
||||
const fbp = <any>bp;
|
||||
@@ -554,7 +554,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<vscode.DebugConfiguration[]> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -566,7 +566,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -579,7 +579,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
// TODO@AW legacy
|
||||
public async $legacyDebugAdapterExecutable(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<IAdapterDescriptor> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -591,7 +591,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
|
||||
let adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
|
||||
const adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
|
||||
if (!adapterProvider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
if (!this._isDisposed) {
|
||||
this._onDidChangeDiagnostics.fire(keys(this._data));
|
||||
this._proxy.$clear(this._owner);
|
||||
this._data = undefined;
|
||||
this._data = undefined!;
|
||||
this._isDisposed = true;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
for (const tuple of first) {
|
||||
const [uri, diagnostics] = tuple;
|
||||
if (!lastUri || uri.toString() !== lastUri.toString()) {
|
||||
if (lastUri && this._data.get(lastUri.toString()).length === 0) {
|
||||
if (lastUri && this._data.get(lastUri.toString())!.length === 0) {
|
||||
this._data.delete(lastUri.toString());
|
||||
}
|
||||
lastUri = uri;
|
||||
@@ -95,9 +95,15 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
|
||||
if (!diagnostics) {
|
||||
// [Uri, undefined] means clear this
|
||||
this._data.get(uri.toString()).length = 0;
|
||||
const currentDiagnostics = this._data.get(uri.toString());
|
||||
if (currentDiagnostics) {
|
||||
currentDiagnostics.length = 0;
|
||||
}
|
||||
} else {
|
||||
this._data.get(uri.toString()).push(...diagnostics);
|
||||
const currentDiagnostics = this._data.get(uri.toString());
|
||||
if (currentDiagnostics) {
|
||||
currentDiagnostics.push(...diagnostics);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,8 +114,8 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
// compute change and send to main side
|
||||
const entries: [URI, IMarkerData[]][] = [];
|
||||
for (let uri of toSync) {
|
||||
let marker: IMarkerData[] | undefined;
|
||||
let diagnostics = this._data.get(uri.toString());
|
||||
let marker: IMarkerData[] = [];
|
||||
const diagnostics = this._data.get(uri.toString());
|
||||
if (diagnostics) {
|
||||
|
||||
// no more than N diagnostics per file
|
||||
@@ -137,7 +143,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
endColumn: marker[marker.length - 1].endColumn
|
||||
});
|
||||
} else {
|
||||
marker = diagnostics.map(converter.Diagnostic.from);
|
||||
marker = diagnostics.map(diag => converter.Diagnostic.from(diag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,18 +170,18 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
forEach(callback: (uri: URI, diagnostics: vscode.Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void {
|
||||
this._checkDisposed();
|
||||
this._data.forEach((value, key) => {
|
||||
let uri = URI.parse(key);
|
||||
const uri = URI.parse(key);
|
||||
callback.apply(thisArg, [uri, this.get(uri), this]);
|
||||
});
|
||||
}
|
||||
|
||||
get(uri: URI): vscode.Diagnostic[] {
|
||||
this._checkDisposed();
|
||||
let result = this._data.get(uri.toString());
|
||||
const result = this._data.get(uri.toString());
|
||||
if (Array.isArray(result)) {
|
||||
return <vscode.Diagnostic[]>Object.freeze(result.slice(0));
|
||||
}
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
|
||||
has(uri: URI): boolean {
|
||||
@@ -218,8 +224,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
|
||||
}
|
||||
|
||||
static _mapper(last: (vscode.Uri | string)[]): { uris: vscode.Uri[] } {
|
||||
let uris: vscode.Uri[] = [];
|
||||
let map = new Set<string>();
|
||||
const uris: vscode.Uri[] = [];
|
||||
const map = new Set<string>();
|
||||
for (const uri of last) {
|
||||
if (typeof uri === 'string') {
|
||||
if (!map.has(uri)) {
|
||||
@@ -279,8 +285,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
|
||||
if (resource) {
|
||||
return this._getDiagnostics(resource);
|
||||
} else {
|
||||
let index = new Map<string, number>();
|
||||
let res: [vscode.Uri, vscode.Diagnostic[]][] = [];
|
||||
const index = new Map<string, number>();
|
||||
const res: [vscode.Uri, vscode.Diagnostic[]][] = [];
|
||||
this._collections.forEach(collection => {
|
||||
collection.forEach((uri, diagnostics) => {
|
||||
let idx = index.get(uri.toString());
|
||||
|
||||
@@ -105,7 +105,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
}
|
||||
|
||||
private _getTextInRange(_range: vscode.Range): string {
|
||||
let range = this._validateRange(_range);
|
||||
const range = this._validateRange(_range);
|
||||
|
||||
if (range.isEmpty) {
|
||||
return '';
|
||||
@@ -115,7 +115,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
return this._lines[range.start.line].substring(range.start.character, range.end.character);
|
||||
}
|
||||
|
||||
let lineEnding = this._eol,
|
||||
const lineEnding = this._eol,
|
||||
startLineIndex = range.start.line,
|
||||
endLineIndex = range.end.line,
|
||||
resultLines: string[] = [];
|
||||
@@ -178,9 +178,9 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
offset = Math.max(0, offset);
|
||||
|
||||
this._ensureLineStarts();
|
||||
let out = this._lineStarts!.getIndexOf(offset);
|
||||
const out = this._lineStarts!.getIndexOf(offset);
|
||||
|
||||
let lineLength = this._lines[out.index].length;
|
||||
const lineLength = this._lines[out.index].length;
|
||||
|
||||
// Ensure we return a valid position
|
||||
return new Position(out.index, Math.min(out.remainder, lineLength));
|
||||
@@ -193,8 +193,8 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
throw new Error('Invalid argument');
|
||||
}
|
||||
|
||||
let start = this._validatePosition(range.start);
|
||||
let end = this._validatePosition(range.end);
|
||||
const start = this._validatePosition(range.start);
|
||||
const end = this._validatePosition(range.end);
|
||||
|
||||
if (start === range.start && end === range.end) {
|
||||
return range;
|
||||
@@ -221,7 +221,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
hasChanged = true;
|
||||
}
|
||||
else {
|
||||
let maxCharacter = this._lines[line].length;
|
||||
const maxCharacter = this._lines[line].length;
|
||||
if (character < 0) {
|
||||
character = 0;
|
||||
hasChanged = true;
|
||||
@@ -239,7 +239,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
}
|
||||
|
||||
private _getWordRangeAtPosition(_position: vscode.Position, regexp?: RegExp): vscode.Range | undefined {
|
||||
let position = this._validatePosition(_position);
|
||||
const position = this._validatePosition(_position);
|
||||
|
||||
if (!regexp) {
|
||||
// use default when custom-regexp isn't provided
|
||||
@@ -251,7 +251,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
regexp = getWordDefinitionFor(this._languageId);
|
||||
}
|
||||
|
||||
let wordAtText = getWordAtText(
|
||||
const wordAtText = getWordAtText(
|
||||
position.character + 1,
|
||||
ensureValidWordDefinition(regexp),
|
||||
this._lines[position.line],
|
||||
|
||||
@@ -53,14 +53,14 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
|
||||
const entries = this._callbacks.toArray();
|
||||
|
||||
let didTimeout = false;
|
||||
let didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
|
||||
const didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
|
||||
|
||||
const promise = sequence(entries.map(listener => {
|
||||
return () => {
|
||||
|
||||
if (didTimeout) {
|
||||
// timeout - no more listeners
|
||||
return undefined;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const document = this._documents.getDocument(resource);
|
||||
|
||||
@@ -77,7 +77,7 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
public ensureDocumentData(uri: URI): Promise<ExtHostDocumentData> {
|
||||
|
||||
let cached = this._documentsAndEditors.getDocument(uri);
|
||||
const cached = this._documentsAndEditors.getDocument(uri);
|
||||
if (cached) {
|
||||
return Promise.resolve(cached);
|
||||
}
|
||||
@@ -103,8 +103,10 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
public $acceptModelModeChanged(uriComponents: UriComponents, oldModeId: string, newModeId: string): void {
|
||||
const uri = URI.revive(uriComponents);
|
||||
let data = this._documentsAndEditors.getDocument(uri);
|
||||
|
||||
const data = this._documentsAndEditors.getDocument(uri);
|
||||
if (!data) {
|
||||
throw new Error('unknown document');
|
||||
}
|
||||
// Treat a mode change as a remove + add
|
||||
|
||||
this._onDidRemoveDocument.fire(data.document);
|
||||
@@ -114,14 +116,20 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
public $acceptModelSaved(uriComponents: UriComponents): void {
|
||||
const uri = URI.revive(uriComponents);
|
||||
let data = this._documentsAndEditors.getDocument(uri);
|
||||
const data = this._documentsAndEditors.getDocument(uri);
|
||||
if (!data) {
|
||||
throw new Error('unknown document');
|
||||
}
|
||||
this.$acceptDirtyStateChanged(uriComponents, false);
|
||||
this._onDidSaveDocument.fire(data.document);
|
||||
}
|
||||
|
||||
public $acceptDirtyStateChanged(uriComponents: UriComponents, isDirty: boolean): void {
|
||||
const uri = URI.revive(uriComponents);
|
||||
let data = this._documentsAndEditors.getDocument(uri);
|
||||
const data = this._documentsAndEditors.getDocument(uri);
|
||||
if (!data) {
|
||||
throw new Error('unknown document');
|
||||
}
|
||||
data._acceptIsDirty(isDirty);
|
||||
this._onDidChangeDocument.fire({
|
||||
document: data.document,
|
||||
@@ -131,7 +139,10 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
public $acceptModelChanged(uriComponents: UriComponents, events: IModelChangedEvent, isDirty: boolean): void {
|
||||
const uri = URI.revive(uriComponents);
|
||||
let data = this._documentsAndEditors.getDocument(uri);
|
||||
const data = this._documentsAndEditors.getDocument(uri);
|
||||
if (!data) {
|
||||
throw new Error('unknown document');
|
||||
}
|
||||
data._acceptIsDirty(isDirty);
|
||||
data.onEvents(events);
|
||||
this._onDidChangeDocument.fire({
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
|
||||
private _disposables: Disposable[] = [];
|
||||
|
||||
private _activeEditorId: string;
|
||||
private _activeEditorId: string | null;
|
||||
|
||||
private readonly _editors = new Map<string, ExtHostTextEditor>();
|
||||
private readonly _documents = new Map<string, ExtHostDocumentData>();
|
||||
@@ -25,12 +25,12 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
private readonly _onDidAddDocuments = new Emitter<ExtHostDocumentData[]>();
|
||||
private readonly _onDidRemoveDocuments = new Emitter<ExtHostDocumentData[]>();
|
||||
private readonly _onDidChangeVisibleTextEditors = new Emitter<ExtHostTextEditor[]>();
|
||||
private readonly _onDidChangeActiveTextEditor = new Emitter<ExtHostTextEditor>();
|
||||
private readonly _onDidChangeActiveTextEditor = new Emitter<ExtHostTextEditor | undefined>();
|
||||
|
||||
readonly onDidAddDocuments: Event<ExtHostDocumentData[]> = this._onDidAddDocuments.event;
|
||||
readonly onDidRemoveDocuments: Event<ExtHostDocumentData[]> = this._onDidRemoveDocuments.event;
|
||||
readonly onDidChangeVisibleTextEditors: Event<ExtHostTextEditor[]> = this._onDidChangeVisibleTextEditors.event;
|
||||
readonly onDidChangeActiveTextEditor: Event<ExtHostTextEditor> = this._onDidChangeActiveTextEditor.event;
|
||||
readonly onDidChangeActiveTextEditor: Event<ExtHostTextEditor | undefined> = this._onDidChangeActiveTextEditor.event;
|
||||
|
||||
constructor(
|
||||
private readonly _mainContext: IMainContext,
|
||||
@@ -93,14 +93,14 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
assert.ok(this._documents.has(resource.toString()), `document '${resource}' does not exist`);
|
||||
assert.ok(!this._editors.has(data.id), `editor '${data.id}' already exists!`);
|
||||
|
||||
const documentData = this._documents.get(resource.toString());
|
||||
const documentData = this._documents.get(resource.toString())!;
|
||||
const editor = new ExtHostTextEditor(
|
||||
this._mainContext.getProxy(MainContext.MainThreadTextEditors),
|
||||
data.id,
|
||||
documentData,
|
||||
data.selections.map(typeConverters.Selection.to),
|
||||
data.options,
|
||||
data.visibleRanges.map(typeConverters.Range.to),
|
||||
data.visibleRanges.map(range => typeConverters.Range.to(range)),
|
||||
typeof data.editorPosition === 'number' ? typeConverters.ViewColumn.to(data.editorPosition) : undefined
|
||||
);
|
||||
this._editors.set(data.id, editor);
|
||||
@@ -131,7 +131,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
}
|
||||
}
|
||||
|
||||
getDocument(uri: URI): ExtHostDocumentData {
|
||||
getDocument(uri: URI): ExtHostDocumentData | undefined {
|
||||
return this._documents.get(uri.toString());
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
return result;
|
||||
}
|
||||
|
||||
getEditor(id: string): ExtHostTextEditor {
|
||||
getEditor(id: string): ExtHostTextEditor | undefined {
|
||||
return this._editors.get(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -238,14 +238,14 @@ export class ExtensionsActivator {
|
||||
if (this._alreadyActivatedEvents[activationEvent]) {
|
||||
return NO_OP_VOID_PROMISE;
|
||||
}
|
||||
let activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
|
||||
const activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
|
||||
return this._activateExtensions(activateExtensions.map(e => e.identifier), reason).then(() => {
|
||||
this._alreadyActivatedEvents[activationEvent] = true;
|
||||
});
|
||||
}
|
||||
|
||||
public activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void> {
|
||||
let desc = this._registry.getExtensionDescription(extensionId);
|
||||
const desc = this._registry.getExtensionDescription(extensionId);
|
||||
if (!desc) {
|
||||
throw new Error('Extension `' + extensionId + '` is not known');
|
||||
}
|
||||
@@ -264,7 +264,7 @@ export class ExtensionsActivator {
|
||||
}
|
||||
|
||||
const currentExtension = this._registry.getExtensionDescription(currentExtensionId)!;
|
||||
let depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
|
||||
const depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
|
||||
let currentExtensionGetsGreenLight = true;
|
||||
|
||||
for (let j = 0, lenJ = depIds.length; j < lenJ; j++) {
|
||||
@@ -330,7 +330,7 @@ export class ExtensionsActivator {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
let greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
|
||||
const greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
|
||||
red: ExtensionIdentifier[] = [];
|
||||
|
||||
for (let i = 0, len = extensionIds.length; i < len; i++) {
|
||||
@@ -345,7 +345,7 @@ export class ExtensionsActivator {
|
||||
}
|
||||
}
|
||||
|
||||
let green = Object.keys(greenMap).map(id => greenMap[id]);
|
||||
const green = Object.keys(greenMap).map(id => greenMap[id]);
|
||||
|
||||
// console.log('greenExtensions: ', green.map(p => p.id));
|
||||
// console.log('redExtensions: ', red.map(p => p.id));
|
||||
|
||||
@@ -116,6 +116,9 @@ class ExtensionStoragePath {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
if (!this._environment.appSettingsHome) {
|
||||
return undefined;
|
||||
}
|
||||
const storageName = this._workspace.id;
|
||||
const storagePath = path.join(this._environment.appSettingsHome.fsPath, 'workspaceStorage', storageName);
|
||||
|
||||
@@ -222,7 +225,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
|
||||
actualActivateExtension: async (extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<ActivatedExtension> => {
|
||||
if (hostExtensions.has(ExtensionIdentifier.toKey(extensionId))) {
|
||||
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
await this._mainThreadExtensionsProxy.$activateExtension(extensionId, activationEvent);
|
||||
return new HostExtension();
|
||||
}
|
||||
@@ -342,7 +345,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
return result;
|
||||
}
|
||||
|
||||
let extension = this._activator.getActivatedExtension(extensionId);
|
||||
const extension = this._activator.getActivatedExtension(extensionId);
|
||||
if (!extension) {
|
||||
return result;
|
||||
}
|
||||
@@ -379,7 +382,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
this._mainThreadExtensionsProxy.$onWillActivateExtension(extensionDescription.identifier);
|
||||
return this._doActivateExtension(extensionDescription, reason).then((activatedExtension) => {
|
||||
const activationTimes = activatedExtension.activationTimes;
|
||||
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
this._mainThreadExtensionsProxy.$onDidActivateExtension(extensionDescription.identifier, activationTimes.startup, activationTimes.codeLoadingTime, activationTimes.activateCallTime, activationTimes.activateResolvedTime, activationEvent);
|
||||
this._logExtensionActivationTimes(extensionDescription, reason, 'success', activationTimes);
|
||||
return activatedExtension;
|
||||
@@ -391,7 +394,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
private _logExtensionActivationTimes(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason, outcome: string, activationTimes?: ExtensionActivationTimes) {
|
||||
let event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
const event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
/* __GDPR__
|
||||
"extensionActivationTimes" : {
|
||||
"${include}": [
|
||||
@@ -409,7 +412,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
private _doActivateExtension(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason): Promise<ActivatedExtension> {
|
||||
let event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
const event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
/* __GDPR__
|
||||
"activatePlugin" : {
|
||||
"${include}": [
|
||||
@@ -436,8 +439,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
|
||||
private _loadExtensionContext(extensionDescription: IExtensionDescription): Promise<IExtensionContext> {
|
||||
|
||||
let globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
|
||||
let workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
|
||||
const globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
|
||||
const workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
|
||||
|
||||
this._extHostLogService.trace(`ExtensionService#loadExtensionContext ${extensionDescription.identifier.value}`);
|
||||
return Promise.all([
|
||||
@@ -760,7 +763,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
public async $test_down(size: number): Promise<Buffer> {
|
||||
let b = Buffer.alloc(size, Math.random() % 256);
|
||||
const b = Buffer.alloc(size, Math.random() % 256);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -796,7 +799,7 @@ function getTelemetryActivationEvent(extensionDescription: IExtensionDescription
|
||||
"reason": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
let event = {
|
||||
const event = {
|
||||
id: extensionDescription.identifier.value,
|
||||
name: extensionDescription.name,
|
||||
extensionVersion: extensionDescription.version,
|
||||
|
||||
@@ -20,7 +20,7 @@ import { CharCode } from 'vs/base/common/charCode';
|
||||
class FsLinkProvider {
|
||||
|
||||
private _schemes: string[] = [];
|
||||
private _stateMachine: StateMachine;
|
||||
private _stateMachine?: StateMachine;
|
||||
|
||||
add(scheme: string): void {
|
||||
this._stateMachine = undefined;
|
||||
@@ -28,7 +28,7 @@ class FsLinkProvider {
|
||||
}
|
||||
|
||||
delete(scheme: string): void {
|
||||
let idx = this._schemes.indexOf(scheme);
|
||||
const idx = this._schemes.indexOf(scheme);
|
||||
if (idx >= 0) {
|
||||
this._schemes.splice(idx, 1);
|
||||
this._stateMachine = undefined;
|
||||
@@ -94,7 +94,7 @@ class FsLinkProvider {
|
||||
}, this._stateMachine);
|
||||
|
||||
for (const link of links) {
|
||||
let docLink = typeConverter.DocumentLink.to(link);
|
||||
const docLink = typeConverter.DocumentLink.to(link);
|
||||
if (docLink.target) {
|
||||
result.push(docLink);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
this._proxy.$registerFileSystemProvider(handle, scheme, capabilites);
|
||||
|
||||
const subscription = provider.onDidChangeFile(event => {
|
||||
let mapped: IFileChangeDto[] = [];
|
||||
const mapped: IFileChangeDto[] = [];
|
||||
for (const e of event) {
|
||||
let { uri: resource, type } = e;
|
||||
if (resource.scheme !== scheme) {
|
||||
@@ -190,6 +190,8 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
case FileChangeType.Deleted:
|
||||
newType = files.FileChangeType.DELETED;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown FileChangeType');
|
||||
}
|
||||
mapped.push({ resource, type: newType });
|
||||
}
|
||||
@@ -219,65 +221,51 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
return { type, ctime, mtime, size };
|
||||
}
|
||||
|
||||
private _checkProviderExists(handle: number): void {
|
||||
if (!this._fsProvider.has(handle)) {
|
||||
const err = new Error();
|
||||
err.name = 'ENOPRO';
|
||||
err.message = `no provider`;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
$stat(handle: number, resource: UriComponents): Promise<files.IStat> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).stat(URI.revive(resource))).then(ExtHostFileSystem._asIStat);
|
||||
return Promise.resolve(this.getProvider(handle).stat(URI.revive(resource))).then(ExtHostFileSystem._asIStat);
|
||||
}
|
||||
|
||||
$readdir(handle: number, resource: UriComponents): Promise<[string, files.FileType][]> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).readDirectory(URI.revive(resource)));
|
||||
return Promise.resolve(this.getProvider(handle).readDirectory(URI.revive(resource)));
|
||||
}
|
||||
|
||||
$readFile(handle: number, resource: UriComponents): Promise<Buffer> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).readFile(URI.revive(resource))).then(data => {
|
||||
return Promise.resolve(this.getProvider(handle).readFile(URI.revive(resource))).then(data => {
|
||||
return Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
});
|
||||
}
|
||||
|
||||
$writeFile(handle: number, resource: UriComponents, content: Buffer, opts: files.FileWriteOptions): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).writeFile(URI.revive(resource), content, opts));
|
||||
return Promise.resolve(this.getProvider(handle).writeFile(URI.revive(resource), content, opts));
|
||||
}
|
||||
|
||||
$delete(handle: number, resource: UriComponents, opts: files.FileDeleteOptions): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).delete(URI.revive(resource), opts));
|
||||
return Promise.resolve(this.getProvider(handle).delete(URI.revive(resource), opts));
|
||||
}
|
||||
|
||||
$rename(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts));
|
||||
return Promise.resolve(this.getProvider(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts));
|
||||
}
|
||||
|
||||
$copy(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts));
|
||||
const provider = this.getProvider(handle);
|
||||
if (!provider.copy) {
|
||||
throw new Error('FileSystemProvider does not implement "copy"');
|
||||
}
|
||||
return Promise.resolve(provider.copy(URI.revive(oldUri), URI.revive(newUri), opts));
|
||||
}
|
||||
|
||||
$mkdir(handle: number, resource: UriComponents): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).createDirectory(URI.revive(resource)));
|
||||
return Promise.resolve(this.getProvider(handle).createDirectory(URI.revive(resource)));
|
||||
}
|
||||
|
||||
$watch(handle: number, session: number, resource: UriComponents, opts: files.IWatchOptions): void {
|
||||
this._checkProviderExists(handle);
|
||||
let subscription = this._fsProvider.get(handle).watch(URI.revive(resource), opts);
|
||||
const subscription = this.getProvider(handle).watch(URI.revive(resource), opts);
|
||||
this._watches.set(session, subscription);
|
||||
}
|
||||
|
||||
$unwatch(_handle: number, session: number): void {
|
||||
let subscription = this._watches.get(session);
|
||||
const subscription = this._watches.get(session);
|
||||
if (subscription) {
|
||||
subscription.dispose();
|
||||
this._watches.delete(session);
|
||||
@@ -285,26 +273,48 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
}
|
||||
|
||||
$open(handle: number, resource: UriComponents, opts: files.FileOpenOptions): Promise<number> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).open(URI.revive(resource), opts));
|
||||
const provider = this.getProvider(handle);
|
||||
if (!provider.open) {
|
||||
throw new Error('FileSystemProvider does not implement "open"');
|
||||
}
|
||||
return Promise.resolve(provider.open(URI.revive(resource), opts));
|
||||
}
|
||||
|
||||
$close(handle: number, fd: number): Promise<void> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).close(fd));
|
||||
const provider = this.getProvider(handle);
|
||||
if (!provider.close) {
|
||||
throw new Error('FileSystemProvider does not implement "close"');
|
||||
}
|
||||
return Promise.resolve(provider.close(fd));
|
||||
}
|
||||
|
||||
$read(handle: number, fd: number, pos: number, length: number): Promise<Buffer> {
|
||||
this._checkProviderExists(handle);
|
||||
const provider = this.getProvider(handle);
|
||||
if (!provider.read) {
|
||||
throw new Error('FileSystemProvider does not implement "read"');
|
||||
}
|
||||
const data = Buffer.allocUnsafe(length);
|
||||
return Promise.resolve(this._fsProvider.get(handle).read(fd, pos, data, 0, length)).then(read => {
|
||||
return Promise.resolve(provider.read(fd, pos, data, 0, length)).then(read => {
|
||||
return data.slice(0, read); // don't send zeros
|
||||
});
|
||||
}
|
||||
|
||||
$write(handle: number, fd: number, pos: number, data: Buffer): Promise<number> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).write(fd, pos, data, 0, data.length));
|
||||
const provider = this.getProvider(handle);
|
||||
if (!provider.write) {
|
||||
throw new Error('FileSystemProvider does not implement "write"');
|
||||
}
|
||||
return Promise.resolve(provider.write(fd, pos, data, 0, data.length));
|
||||
}
|
||||
|
||||
private getProvider(handle: number): vscode.FileSystemProvider {
|
||||
const provider = this._fsProvider.get(handle);
|
||||
if (!provider) {
|
||||
const err = new Error();
|
||||
err.name = 'ENOPRO';
|
||||
err.message = `no provider`;
|
||||
throw err;
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
|
||||
const parsedPattern = parse(globPattern);
|
||||
|
||||
let subscription = dispatcher(events => {
|
||||
const subscription = dispatcher(events => {
|
||||
if (!ignoreCreateEvents) {
|
||||
for (let created of events.created) {
|
||||
let uri = URI.revive(created);
|
||||
const uri = URI.revive(created);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidCreate.fire(uri);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
}
|
||||
if (!ignoreChangeEvents) {
|
||||
for (let changed of events.changed) {
|
||||
let uri = URI.revive(changed);
|
||||
const uri = URI.revive(changed);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidChange.fire(uri);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
}
|
||||
if (!ignoreDeleteEvents) {
|
||||
for (let deleted of events.deleted) {
|
||||
let uri = URI.revive(deleted);
|
||||
const uri = URI.revive(deleted);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidDelete.fire(uri);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
|
||||
}
|
||||
// flatten all WorkspaceEdits collected via waitUntil-call
|
||||
// and apply them in one go.
|
||||
let allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
|
||||
const allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
|
||||
for (let edit of edits) {
|
||||
if (edit) { // sparse array
|
||||
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);
|
||||
|
||||
@@ -65,10 +65,10 @@ class DocumentSymbolAdapter {
|
||||
}
|
||||
return res;
|
||||
});
|
||||
let res: modes.DocumentSymbol[] = [];
|
||||
let parentStack: modes.DocumentSymbol[] = [];
|
||||
const res: modes.DocumentSymbol[] = [];
|
||||
const parentStack: modes.DocumentSymbol[] = [];
|
||||
for (const info of infos) {
|
||||
let element = <modes.DocumentSymbol>{
|
||||
const element = <modes.DocumentSymbol>{
|
||||
name: info.name || '!!MISSING: name!!',
|
||||
kind: typeConvert.SymbolKind.from(info.kind),
|
||||
containerName: info.containerName,
|
||||
@@ -83,7 +83,7 @@ class DocumentSymbolAdapter {
|
||||
res.push(element);
|
||||
break;
|
||||
}
|
||||
let parent = parentStack[parentStack.length - 1];
|
||||
const parent = parentStack[parentStack.length - 1];
|
||||
if (EditorRange.containsRange(parent.range, element.range) && !EditorRange.equalsRange(parent.range, element.range)) {
|
||||
parent.children.push(element);
|
||||
parentStack.push(element);
|
||||
@@ -111,7 +111,7 @@ class CodeLensAdapter {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
|
||||
return asPromise(() => this._provider.provideCodeLenses(doc, token)).then(lenses => {
|
||||
let result: CodeLensDto[] = [];
|
||||
const result: CodeLensDto[] = [];
|
||||
if (isNonEmptyArray(lenses)) {
|
||||
for (const lens of lenses) {
|
||||
const id = this._heapService.keep(lens);
|
||||
@@ -206,7 +206,7 @@ class DefinitionAdapter {
|
||||
|
||||
provideDefinition(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideDefinition(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class DeclarationAdapter {
|
||||
|
||||
provideDeclaration(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideDeclaration(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -234,7 +234,7 @@ class ImplementationAdapter {
|
||||
|
||||
provideImplementation(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideImplementation(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class HoverAdapter {
|
||||
public provideHover(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.Hover | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideHover(doc, pos, token)).then(value => {
|
||||
if (!value || isFalsyOrEmpty(value.contents)) {
|
||||
@@ -291,7 +291,7 @@ class DocumentHighlightAdapter {
|
||||
provideDocumentHighlights(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DocumentHighlight[] | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideDocumentHighlights(doc, pos, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -311,7 +311,7 @@ class ReferenceAdapter {
|
||||
|
||||
provideReferences(resource: URI, position: IPosition, context: modes.ReferenceContext, token: CancellationToken): Promise<modes.Location[] | undefined> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideReferences(doc, pos, context, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -546,7 +546,7 @@ class RenameAdapter {
|
||||
provideRenameEdits(resource: URI, position: IPosition, newName: string, token: CancellationToken): Promise<WorkspaceEditDto | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
|
||||
if (!value) {
|
||||
@@ -554,7 +554,7 @@ class RenameAdapter {
|
||||
}
|
||||
return typeConvert.WorkspaceEdit.from(value);
|
||||
}, err => {
|
||||
let rejectReason = RenameAdapter._asMessage(err);
|
||||
const rejectReason = RenameAdapter._asMessage(err);
|
||||
if (rejectReason) {
|
||||
return <WorkspaceEditDto>{ rejectReason, edits: undefined! };
|
||||
} else {
|
||||
@@ -570,7 +570,7 @@ class RenameAdapter {
|
||||
}
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.prepareRename!(doc, pos, token)).then(rangeOrLocation => {
|
||||
|
||||
@@ -594,7 +594,7 @@ class RenameAdapter {
|
||||
}
|
||||
return { range: typeConvert.Range.from(range), text };
|
||||
}, err => {
|
||||
let rejectReason = RenameAdapter._asMessage(err);
|
||||
const rejectReason = RenameAdapter._asMessage(err);
|
||||
if (rejectReason) {
|
||||
return <modes.RenameLocation & modes.Rejection>{ rejectReason, range: undefined!, text: undefined! };
|
||||
} else {
|
||||
@@ -832,8 +832,8 @@ class LinkProviderAdapter {
|
||||
}
|
||||
const result: LinkDto[] = [];
|
||||
for (const link of links) {
|
||||
let data = typeConvert.DocumentLink.from(link);
|
||||
let id = this._heapService.keep(link);
|
||||
const data = typeConvert.DocumentLink.from(link);
|
||||
const id = this._heapService.keep(link);
|
||||
result.push(ObjectIdentifier.mixin(data, id));
|
||||
}
|
||||
return result;
|
||||
@@ -936,7 +936,7 @@ class SelectionRangeAdapter {
|
||||
return [];
|
||||
}
|
||||
|
||||
let allResults: modes.SelectionRange[][] = [];
|
||||
const allResults: modes.SelectionRange[][] = [];
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
const oneResult: modes.SelectionRange[] = [];
|
||||
allResults.push(oneResult);
|
||||
@@ -1065,7 +1065,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
||||
t1 = Date.now();
|
||||
this._logService.trace(`[${data.extension.identifier.value}] INVOKE provider '${(ctor as any).name}'`);
|
||||
}
|
||||
let p = callback(data.adapter, data.extension);
|
||||
const p = callback(data.adapter, data.extension);
|
||||
const extension = data.extension;
|
||||
if (extension) {
|
||||
Promise.resolve(p).then(
|
||||
@@ -1081,7 +1081,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
||||
return Promise.reject(new Error('no adapter found'));
|
||||
}
|
||||
|
||||
private _addNewAdapter(adapter: Adapter, extension: IExtensionDescription): number {
|
||||
private _addNewAdapter(adapter: Adapter, extension: IExtensionDescription | undefined): number {
|
||||
const handle = this._nextHandle();
|
||||
this._adapter.set(handle, new AdapterData(adapter, extension));
|
||||
return handle;
|
||||
@@ -1358,7 +1358,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
||||
|
||||
// --- links
|
||||
|
||||
registerDocumentLinkProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
|
||||
registerDocumentLinkProvider(extension: IExtensionDescription | undefined, selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
|
||||
const handle = this._addNewAdapter(new LinkProviderAdapter(this._documents, this._heapService, provider), extension);
|
||||
this._proxy.$registerDocumentLinkProvider(handle, this._transformDocumentSelector(selector));
|
||||
return this._createDisposable(handle);
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ExtHostMessageService {
|
||||
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem, rest: vscode.MessageItem[]): Promise<vscode.MessageItem | undefined>;
|
||||
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | vscode.MessageItem, rest: (string | vscode.MessageItem)[]): Promise<string | vscode.MessageItem | undefined> {
|
||||
|
||||
let options: MainThreadMessageOptions = { extension };
|
||||
const options: MainThreadMessageOptions = { extension };
|
||||
let items: (string | vscode.MessageItem)[];
|
||||
|
||||
if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
|
||||
@@ -37,7 +37,7 @@ export class ExtHostMessageService {
|
||||
const commands: { title: string; isCloseAffordance: boolean; handle: number; }[] = [];
|
||||
|
||||
for (let handle = 0; handle < items.length; handle++) {
|
||||
let command = items[handle];
|
||||
const command = items[handle];
|
||||
if (typeof command === 'string') {
|
||||
commands.push({ title: command, handle, isCloseAffordance: false });
|
||||
} else if (typeof command === 'object') {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { ThemeIcon, QuickInputButtons } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
|
||||
export type Item = string | QuickPickItem;
|
||||
|
||||
@@ -24,7 +25,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
||||
private _workspace: IExtHostWorkspaceProvider;
|
||||
private _commands: ExtHostCommands;
|
||||
|
||||
private _onDidSelectItem: (handle: number) => void;
|
||||
private _onDidSelectItem?: (handle: number) => void;
|
||||
private _validateInput?: (input: string) => string | undefined | null | Thenable<string | undefined | null>;
|
||||
|
||||
private _sessions = new Map<number, ExtHostQuickInput>();
|
||||
@@ -67,10 +68,10 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
||||
|
||||
return itemsPromise.then(items => {
|
||||
|
||||
let pickItems: TransferQuickPickItems[] = [];
|
||||
const pickItems: TransferQuickPickItems[] = [];
|
||||
for (let handle = 0; handle < items.length; handle++) {
|
||||
|
||||
let item = items[handle];
|
||||
const item = items[handle];
|
||||
let label: string;
|
||||
let description: string | undefined;
|
||||
let detail: string | undefined;
|
||||
@@ -158,12 +159,15 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
||||
|
||||
// ---- workspace folder picker
|
||||
|
||||
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder> {
|
||||
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder | undefined> {
|
||||
return this._commands.executeCommand('_workbench.pickWorkspaceFolder', [options]).then(async (selectedFolder: WorkspaceFolder) => {
|
||||
if (!selectedFolder) {
|
||||
return undefined;
|
||||
}
|
||||
const workspaceFolders = await this._workspace.getWorkspaceFolders2();
|
||||
if (!workspaceFolders) {
|
||||
return undefined;
|
||||
}
|
||||
return workspaceFolders.filter(folder => folder.uri.toString() === selectedFolder.uri.toString())[0];
|
||||
});
|
||||
}
|
||||
@@ -382,7 +386,9 @@ class ExtHostQuickInput implements QuickInput {
|
||||
|
||||
_fireDidTriggerButton(handle: number) {
|
||||
const button = this._handlesToButtons.get(handle);
|
||||
this._onDidTriggerButtonEmitter.fire(button);
|
||||
if (button) {
|
||||
this._onDidTriggerButtonEmitter.fire(button);
|
||||
}
|
||||
}
|
||||
|
||||
_fireDidHide() {
|
||||
@@ -437,9 +443,13 @@ class ExtHostQuickInput implements QuickInput {
|
||||
}
|
||||
}
|
||||
|
||||
function getIconUris(iconPath: QuickInputButton['iconPath']) {
|
||||
function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light?: URI } | undefined {
|
||||
const dark = getDarkIconUri(iconPath);
|
||||
const light = getLightIconUri(iconPath);
|
||||
return { dark: getDarkIconUri(iconPath) || light, light };
|
||||
if (!light && !dark) {
|
||||
return undefined;
|
||||
}
|
||||
return { dark: (dark || light)!, light };
|
||||
}
|
||||
|
||||
function getLightIconUri(iconPath: QuickInputButton['iconPath']) {
|
||||
@@ -563,13 +573,13 @@ class ExtHostQuickPick<T extends QuickPickItem> extends ExtHostQuickInput implem
|
||||
onDidChangeSelection = this._onDidChangeSelectionEmitter.event;
|
||||
|
||||
_fireDidChangeActive(handles: number[]) {
|
||||
const items = handles.map(handle => this._handlesToItems.get(handle));
|
||||
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
|
||||
this._activeItems = items;
|
||||
this._onDidChangeActiveEmitter.fire(items);
|
||||
}
|
||||
|
||||
_fireDidChangeSelection(handles: number[]) {
|
||||
const items = handles.map(handle => this._handlesToItems.get(handle));
|
||||
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
|
||||
this._selectedItems = items;
|
||||
this._onDidChangeSelectionEmitter.fire(items);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape } from './extHost.protocol';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, CommandDto } from './extHost.protocol';
|
||||
import { sortedDiff } from 'vs/base/common/arrays';
|
||||
import { comparePaths } from 'vs/base/common/comparers';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -23,7 +23,7 @@ type ProviderHandle = number;
|
||||
type GroupHandle = number;
|
||||
type ResourceStateHandle = number;
|
||||
|
||||
function getIconPath(decorations: vscode.SourceControlResourceThemableDecorations) {
|
||||
function getIconPath(decorations?: vscode.SourceControlResourceThemableDecorations): string | undefined {
|
||||
if (!decorations) {
|
||||
return undefined;
|
||||
} else if (typeof decorations.iconPath === 'string') {
|
||||
@@ -60,7 +60,7 @@ function compareResourceStatesDecorations(a: vscode.SourceControlResourceDecorat
|
||||
}
|
||||
|
||||
if (a.tooltip !== b.tooltip) {
|
||||
return (a.tooltip || '').localeCompare(b.tooltip);
|
||||
return (a.tooltip || '').localeCompare(b.tooltip || '');
|
||||
}
|
||||
|
||||
result = compareResourceThemableDecorations(a, b);
|
||||
@@ -205,7 +205,7 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
|
||||
return this._visible;
|
||||
}
|
||||
|
||||
set visible(visible: boolean | undefined) {
|
||||
set visible(visible: boolean) {
|
||||
visible = !!visible;
|
||||
this._visible = visible;
|
||||
this._proxy.$setInputBoxVisibility(this._sourceControlHandle, visible);
|
||||
@@ -287,7 +287,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return asPromise(() => this._commands.executeCommand(command.command, ...command.arguments));
|
||||
return asPromise(() => this._commands.executeCommand(command.command, ...(command.arguments || [])));
|
||||
}
|
||||
|
||||
_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
|
||||
@@ -309,11 +309,11 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
this._resourceStatesCommandsMap.set(handle, r.command);
|
||||
}
|
||||
|
||||
if (lightIconPath || darkIconPath) {
|
||||
if (lightIconPath) {
|
||||
icons.push(lightIconPath);
|
||||
}
|
||||
|
||||
if (darkIconPath !== lightIconPath) {
|
||||
if (darkIconPath && (darkIconPath !== lightIconPath)) {
|
||||
icons.push(darkIconPath);
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
||||
|
||||
this._statusBarCommands = statusBarCommands;
|
||||
|
||||
const internal = (statusBarCommands || []).map(c => this._commands.converter.toInternal(c));
|
||||
const internal = (statusBarCommands || []).map(c => this._commands.converter.toInternal(c)) as CommandDto[];
|
||||
this._proxy.$updateSourceControl(this.handle, { statusBarCommands: internal });
|
||||
}
|
||||
|
||||
@@ -599,14 +599,12 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox {
|
||||
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox | undefined {
|
||||
this.logService.trace('ExtHostSCM#getLastInputBox', extension.identifier.value);
|
||||
|
||||
const sourceControls = this._sourceControlsByExtension.get(ExtensionIdentifier.toKey(extension.identifier));
|
||||
const sourceControl = sourceControls && sourceControls[sourceControls.length - 1];
|
||||
const inputBox = sourceControl && sourceControl.inputBox;
|
||||
|
||||
return inputBox;
|
||||
return sourceControl && sourceControl.inputBox;
|
||||
}
|
||||
|
||||
$provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise<UriComponents | null> {
|
||||
@@ -615,11 +613,12 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
||||
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
||||
if (!sourceControl || !sourceControl.quickDiffProvider) {
|
||||
if (!sourceControl || !sourceControl.quickDiffProvider || !sourceControl.quickDiffProvider.provideOriginalResource) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asPromise(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
|
||||
return asPromise(() => sourceControl.quickDiffProvider!.provideOriginalResource!(uri, token))
|
||||
.then<UriComponents | null>(r => r || null);
|
||||
}
|
||||
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): Promise<void> {
|
||||
|
||||
@@ -116,7 +116,7 @@ export class FileIndexSearchEngine {
|
||||
}
|
||||
|
||||
private searchInFolder(fq: IFolderQuery<URI>, onResult: (match: IInternalFileMatch) => void): Promise<IFileIndexProviderStats> {
|
||||
let cancellation = new CancellationTokenSource();
|
||||
const cancellation = new CancellationTokenSource();
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = this.getSearchOptionsForFolder(fq);
|
||||
const tree = this.initDirectoryTree();
|
||||
@@ -511,10 +511,10 @@ export class FileIndexSearchManager {
|
||||
}
|
||||
|
||||
// Pattern match on results
|
||||
let results: IInternalFileMatch[] = [];
|
||||
const results: IInternalFileMatch[] = [];
|
||||
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
|
||||
for (let i = 0; i < complete.results.length; i++) {
|
||||
let entry = complete.results[i];
|
||||
const entry = complete.results[i];
|
||||
|
||||
// Check if this entry is a match for the search value
|
||||
if (!strings.fuzzyContains(entry.relativePath!, normalizedSearchValueLowercase)) {
|
||||
|
||||
@@ -139,7 +139,7 @@ class StatusBarMessage {
|
||||
this._update();
|
||||
|
||||
return new Disposable(() => {
|
||||
let idx = this._messages.indexOf(data);
|
||||
const idx = this._messages.indexOf(data);
|
||||
if (idx >= 0) {
|
||||
this._messages.splice(idx, 1);
|
||||
this._update();
|
||||
@@ -173,7 +173,7 @@ export class ExtHostStatusBar {
|
||||
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): Disposable {
|
||||
|
||||
let d = this._statusMessage.setMessage(text);
|
||||
const d = this._statusMessage.setMessage(text);
|
||||
let handle: any;
|
||||
|
||||
if (typeof timeoutOrThenable === 'number') {
|
||||
|
||||
@@ -80,14 +80,14 @@ namespace ProcessExecutionOptionsDTO {
|
||||
|
||||
namespace ProcessExecutionDTO {
|
||||
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecutionDTO): value is ProcessExecutionDTO {
|
||||
let candidate = value as ProcessExecutionDTO;
|
||||
const candidate = value as ProcessExecutionDTO;
|
||||
return candidate && !!candidate.process;
|
||||
}
|
||||
export function from(value: vscode.ProcessExecution): ProcessExecutionDTO {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined;
|
||||
}
|
||||
let result: ProcessExecutionDTO = {
|
||||
const result: ProcessExecutionDTO = {
|
||||
process: value.process,
|
||||
args: value.args
|
||||
};
|
||||
@@ -121,14 +121,14 @@ namespace ShellExecutionOptionsDTO {
|
||||
|
||||
namespace ShellExecutionDTO {
|
||||
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecutionDTO): value is ShellExecutionDTO {
|
||||
let candidate = value as ShellExecutionDTO;
|
||||
const candidate = value as ShellExecutionDTO;
|
||||
return candidate && (!!candidate.commandLine || !!candidate.command);
|
||||
}
|
||||
export function from(value: vscode.ShellExecution): ShellExecutionDTO {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined;
|
||||
}
|
||||
let result: ShellExecutionDTO = {
|
||||
const result: ShellExecutionDTO = {
|
||||
};
|
||||
if (value.commandLine !== undefined) {
|
||||
result.commandLine = value.commandLine;
|
||||
@@ -185,9 +185,9 @@ namespace TaskDTO {
|
||||
if (tasks === undefined || tasks === null) {
|
||||
return [];
|
||||
}
|
||||
let result: TaskDTO[] = [];
|
||||
const result: TaskDTO[] = [];
|
||||
for (let task of tasks) {
|
||||
let converted = from(task, extension);
|
||||
const converted = from(task, extension);
|
||||
if (converted) {
|
||||
result.push(converted);
|
||||
}
|
||||
@@ -207,8 +207,7 @@ namespace TaskDTO {
|
||||
} else if ((<vscode.Task2>value).execution2 && (<vscode.Task2>value).execution2 instanceof types.CustomExecution) {
|
||||
execution = CustomExecutionDTO.from(<types.CustomExecution>(<vscode.Task2>value).execution2);
|
||||
}
|
||||
|
||||
let definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
|
||||
const definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
|
||||
let scope: number | UriComponents;
|
||||
if (value.scope) {
|
||||
if (typeof value.scope === 'number') {
|
||||
@@ -223,8 +222,8 @@ namespace TaskDTO {
|
||||
if (!definition || !scope) {
|
||||
return undefined;
|
||||
}
|
||||
let group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
|
||||
let result: TaskDTO = {
|
||||
const group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
|
||||
const result: TaskDTO = {
|
||||
_id: (value as types.Task)._id,
|
||||
definition,
|
||||
name: value.name,
|
||||
@@ -253,7 +252,7 @@ namespace TaskDTO {
|
||||
} else if (ShellExecutionDTO.is(value.execution)) {
|
||||
execution = ShellExecutionDTO.to(value.execution);
|
||||
}
|
||||
let definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
|
||||
const definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
|
||||
let scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
|
||||
if (value.source) {
|
||||
if (value.source.scope !== undefined) {
|
||||
@@ -269,7 +268,7 @@ namespace TaskDTO {
|
||||
if (!definition || !scope) {
|
||||
return undefined;
|
||||
}
|
||||
let result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
|
||||
const result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
|
||||
if (value.isBackground !== undefined) {
|
||||
result.isBackground = value.isBackground;
|
||||
}
|
||||
@@ -455,7 +454,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
if (!provider) {
|
||||
return new types.Disposable(() => { });
|
||||
}
|
||||
let handle = this.nextHandle();
|
||||
const handle = this.nextHandle();
|
||||
this._handlers.set(handle, { provider, extension });
|
||||
this._proxy.$registerTaskProvider(handle);
|
||||
return new types.Disposable(() => {
|
||||
@@ -470,9 +469,9 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
|
||||
public fetchTasks(filter?: vscode.TaskFilter): Promise<vscode.Task[]> {
|
||||
return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then(async (values) => {
|
||||
let result: vscode.Task[] = [];
|
||||
const result: vscode.Task[] = [];
|
||||
for (let value of values) {
|
||||
let task = await TaskDTO.to(value, this._workspaceProvider);
|
||||
const task = await TaskDTO.to(value, this._workspaceProvider);
|
||||
if (task) {
|
||||
result.push(task);
|
||||
}
|
||||
@@ -482,12 +481,12 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public async executeTask(extension: IExtensionDescription, task: vscode.Task): Promise<vscode.TaskExecution> {
|
||||
let tTask = (task as types.Task);
|
||||
const tTask = (task as types.Task);
|
||||
// We have a preserved ID. So the task didn't change.
|
||||
if (tTask._id !== undefined) {
|
||||
return this._proxy.$executeTask(TaskHandleDTO.from(tTask)).then(value => this.getTaskExecution(value, task));
|
||||
} else {
|
||||
let dto = TaskDTO.from(task, extension);
|
||||
const dto = TaskDTO.from(task, extension);
|
||||
if (dto === undefined) {
|
||||
return Promise.reject(new Error('Task is not valid'));
|
||||
}
|
||||
@@ -496,7 +495,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public get taskExecutions(): vscode.TaskExecution[] {
|
||||
let result: vscode.TaskExecution[] = [];
|
||||
const result: vscode.TaskExecution[] = [];
|
||||
this._taskExecutions.forEach(value => result.push(value));
|
||||
return result;
|
||||
}
|
||||
@@ -579,7 +578,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<TaskSetDTO> {
|
||||
let handler = this._handlers.get(handle);
|
||||
const handler = this._handlers.get(handle);
|
||||
if (!handler) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -597,8 +596,8 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
// The task start event is also the first time we see the ID from the main
|
||||
// thread, which is too late for us because we need to save an map
|
||||
// from an ID to the custom execution function. (Kind of a cart before the horse problem).
|
||||
let taskIdPromises: Promise<void>[] = [];
|
||||
let fetchPromise = asPromise(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
const taskIdPromises: Promise<void>[] = [];
|
||||
const fetchPromise = asPromise(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
const taskDTOs: TaskDTO[] = [];
|
||||
for (let task of value) {
|
||||
if (!task.definition || !validTypes[task.definition.type]) {
|
||||
@@ -638,15 +637,15 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
|
||||
public async $resolveVariables(uriComponents: UriComponents, toResolve: { process?: { name: string; cwd?: string; path?: string }, variables: string[] }): Promise<{ process?: string, variables: { [key: string]: string; } }> {
|
||||
const configProvider = await this._configurationService.getConfigProvider();
|
||||
let uri: URI = URI.revive(uriComponents);
|
||||
let result = {
|
||||
const uri: URI = URI.revive(uriComponents);
|
||||
const result = {
|
||||
process: undefined as string,
|
||||
variables: Object.create(null)
|
||||
};
|
||||
let workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
|
||||
const workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
|
||||
const workspaceFolders = await this._workspaceProvider.getWorkspaceFolders2();
|
||||
let resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
|
||||
let ws: IWorkspaceFolder = {
|
||||
const resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
|
||||
const ws: IWorkspaceFolder = {
|
||||
uri: workspaceFolder.uri,
|
||||
name: workspaceFolder.name,
|
||||
index: workspaceFolder.index,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IMainContext, ShellLaunchConfigDto } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { EXT_HOST_CREATION_DELAY } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { EXT_HOST_CREATION_DELAY, IShellLaunchConfig } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TerminalProcess } from 'vs/workbench/contrib/terminal/node/terminalProcess';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
|
||||
@@ -441,7 +441,15 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
|
||||
}
|
||||
}
|
||||
|
||||
public async $createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number): Promise<void> {
|
||||
public async $createProcess(id: number, shellLaunchConfigDto: ShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number): Promise<void> {
|
||||
const shellLaunchConfig: IShellLaunchConfig = {
|
||||
name: shellLaunchConfigDto.name,
|
||||
executable: shellLaunchConfigDto.executable,
|
||||
args: shellLaunchConfigDto.args,
|
||||
cwd: typeof shellLaunchConfigDto.cwd === 'string' ? shellLaunchConfigDto.cwd : URI.revive(shellLaunchConfigDto.cwd),
|
||||
env: shellLaunchConfigDto.env
|
||||
};
|
||||
|
||||
// TODO: This function duplicates a lot of TerminalProcessManager.createProcess, ideally
|
||||
// they would be merged into a single implementation.
|
||||
const configProvider = await this._extHostConfiguration.getConfigProvider();
|
||||
|
||||
@@ -35,7 +35,7 @@ export class TextEditorDecorationType implements vscode.TextEditorDecorationType
|
||||
|
||||
export interface ITextEditOperation {
|
||||
range: vscode.Range;
|
||||
text: string;
|
||||
text: string | null;
|
||||
forceMoveMarkers: boolean;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ export class TextEditorEdit {
|
||||
this._pushEdit(range, null, true);
|
||||
}
|
||||
|
||||
private _pushEdit(range: Range, text: string, forceMoveMarkers: boolean): void {
|
||||
let validRange = this._document.validateRange(range);
|
||||
private _pushEdit(range: Range, text: string | null, forceMoveMarkers: boolean): void {
|
||||
const validRange = this._document.validateRange(range);
|
||||
this._collectedEdits.push({
|
||||
range: validRange,
|
||||
text: text,
|
||||
@@ -170,11 +170,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
return 'auto';
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
let r = Math.floor(value);
|
||||
const r = Math.floor(value);
|
||||
return (r > 0 ? r : null);
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
let r = parseInt(value, 10);
|
||||
const r = parseInt(value, 10);
|
||||
if (isNaN(r)) {
|
||||
return null;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set tabSize(value: number | string) {
|
||||
let tabSize = this._validateTabSize(value);
|
||||
const tabSize = this._validateTabSize(value);
|
||||
if (tabSize === null) {
|
||||
// ignore invalid call
|
||||
return;
|
||||
@@ -211,11 +211,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
return 'tabSize';
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
let r = Math.floor(value);
|
||||
const r = Math.floor(value);
|
||||
return (r > 0 ? r : null);
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
let r = parseInt(value, 10);
|
||||
const r = parseInt(value, 10);
|
||||
if (isNaN(r)) {
|
||||
return null;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set indentSize(value: number | string) {
|
||||
let indentSize = this._validateIndentSize(value);
|
||||
const indentSize = this._validateIndentSize(value);
|
||||
if (indentSize === null) {
|
||||
// ignore invalid call
|
||||
return;
|
||||
@@ -255,7 +255,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set insertSpaces(value: boolean | string) {
|
||||
let insertSpaces = this._validateInsertSpaces(value);
|
||||
const insertSpaces = this._validateInsertSpaces(value);
|
||||
if (typeof insertSpaces === 'boolean') {
|
||||
if (this._insertSpaces === insertSpaces) {
|
||||
// nothing to do
|
||||
@@ -300,11 +300,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public assign(newOptions: vscode.TextEditorOptions) {
|
||||
let bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
|
||||
const bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
|
||||
let hasUpdate = false;
|
||||
|
||||
if (typeof newOptions.tabSize !== 'undefined') {
|
||||
let tabSize = this._validateTabSize(newOptions.tabSize);
|
||||
const tabSize = this._validateTabSize(newOptions.tabSize);
|
||||
if (tabSize === 'auto') {
|
||||
hasUpdate = true;
|
||||
bulkConfigurationUpdate.tabSize = tabSize;
|
||||
@@ -317,7 +317,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
// if (typeof newOptions.indentSize !== 'undefined') {
|
||||
// let indentSize = this._validateIndentSize(newOptions.indentSize);
|
||||
// const indentSize = this._validateIndentSize(newOptions.indentSize);
|
||||
// if (indentSize === 'tabSize') {
|
||||
// hasUpdate = true;
|
||||
// bulkConfigurationUpdate.indentSize = indentSize;
|
||||
@@ -330,7 +330,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
// }
|
||||
|
||||
if (typeof newOptions.insertSpaces !== 'undefined') {
|
||||
let insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
|
||||
const insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
|
||||
if (insertSpaces === 'auto') {
|
||||
hasUpdate = true;
|
||||
bulkConfigurationUpdate.insertSpaces = insertSpaces;
|
||||
@@ -373,7 +373,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
private _selections: Selection[];
|
||||
private _options: ExtHostTextEditorOptions;
|
||||
private _visibleRanges: Range[];
|
||||
private _viewColumn: vscode.ViewColumn;
|
||||
private _viewColumn: vscode.ViewColumn | undefined;
|
||||
private _disposed: boolean = false;
|
||||
private _hasDecorationsForKey: { [key: string]: boolean; };
|
||||
|
||||
@@ -382,7 +382,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
constructor(
|
||||
proxy: MainThreadTextEditorsShape, id: string, document: ExtHostDocumentData,
|
||||
selections: Selection[], options: IResolvedTextEditorConfiguration,
|
||||
visibleRanges: Range[], viewColumn: vscode.ViewColumn
|
||||
visibleRanges: Range[], viewColumn: vscode.ViewColumn | undefined
|
||||
) {
|
||||
this._proxy = proxy;
|
||||
this._id = id;
|
||||
@@ -451,7 +451,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
|
||||
// ---- view column
|
||||
|
||||
get viewColumn(): vscode.ViewColumn {
|
||||
get viewColumn(): vscode.ViewColumn | undefined {
|
||||
return this._viewColumn;
|
||||
}
|
||||
|
||||
@@ -510,7 +510,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
TypeConverters.fromRangeOrRangeWithMessage(ranges)
|
||||
);
|
||||
} else {
|
||||
let _ranges: number[] = new Array<number>(4 * ranges.length);
|
||||
const _ranges: number[] = new Array<number>(4 * ranges.length);
|
||||
for (let i = 0, len = ranges.length; i < len; i++) {
|
||||
const range = ranges[i];
|
||||
_ranges[4 * i] = range.start.line + 1;
|
||||
@@ -538,8 +538,8 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
);
|
||||
}
|
||||
|
||||
private _trySetSelection(): Promise<vscode.TextEditor> {
|
||||
let selection = this._selections.map(TypeConverters.Selection.from);
|
||||
private _trySetSelection(): Promise<vscode.TextEditor | null | undefined> {
|
||||
const selection = this._selections.map(TypeConverters.Selection.from);
|
||||
return this._runOnProxy(() => this._proxy.$trySetSelections(this._id, selection));
|
||||
}
|
||||
|
||||
@@ -554,13 +554,13 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
if (this._disposed) {
|
||||
return Promise.reject(new Error('TextEditor#edit not possible on closed editors'));
|
||||
}
|
||||
let edit = new TextEditorEdit(this._documentData.document, options);
|
||||
const edit = new TextEditorEdit(this._documentData.document, options);
|
||||
callback(edit);
|
||||
return this._applyEdit(edit);
|
||||
}
|
||||
|
||||
private _applyEdit(editBuilder: TextEditorEdit): Promise<boolean> {
|
||||
let editData = editBuilder.finalize();
|
||||
const editData = editBuilder.finalize();
|
||||
|
||||
// return when there is nothing to do
|
||||
if (editData.edits.length === 0 && !editData.setEndOfLine) {
|
||||
@@ -568,7 +568,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
|
||||
// check that the edits are not overlapping (i.e. illegal)
|
||||
let editRanges = editData.edits.map(edit => edit.range);
|
||||
const editRanges = editData.edits.map(edit => edit.range);
|
||||
|
||||
// sort ascending (by end and then by start)
|
||||
editRanges.sort((a, b) => {
|
||||
@@ -598,7 +598,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
|
||||
// prepare data for serialization
|
||||
let edits: ISingleEditOperation[] = editData.edits.map((edit) => {
|
||||
const edits = editData.edits.map((edit): ISingleEditOperation => {
|
||||
return {
|
||||
range: TypeConverters.Range.from(edit.range),
|
||||
text: edit.text,
|
||||
@@ -620,7 +620,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
let ranges: IRange[];
|
||||
|
||||
if (!where || (Array.isArray(where) && where.length === 0)) {
|
||||
ranges = this._selections.map(TypeConverters.Range.from);
|
||||
ranges = this._selections.map(range => TypeConverters.Range.from(range));
|
||||
|
||||
} else if (where instanceof Position) {
|
||||
const { lineNumber, column } = TypeConverters.Position.from(where);
|
||||
@@ -645,7 +645,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
|
||||
// ---- util
|
||||
|
||||
private _runOnProxy(callback: () => Promise<any>): Promise<ExtHostTextEditor> {
|
||||
private _runOnProxy(callback: () => Promise<any>): Promise<ExtHostTextEditor | undefined | null> {
|
||||
if (this._disposed) {
|
||||
console.warn('TextEditor is closed/disposed');
|
||||
return Promise.resolve(undefined);
|
||||
|
||||
@@ -75,7 +75,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
}
|
||||
|
||||
return this._proxy.$tryShowTextDocument(document.uri, options).then(id => {
|
||||
let editor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
const editor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
if (editor) {
|
||||
return editor;
|
||||
} else {
|
||||
@@ -97,6 +97,9 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
|
||||
$acceptEditorPropertiesChanged(id: string, data: IEditorPropertiesChangeData): void {
|
||||
const textEditor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
if (!textEditor) {
|
||||
throw new Error('unknown text editor');
|
||||
}
|
||||
|
||||
// (1) set all properties
|
||||
if (data.options) {
|
||||
@@ -137,9 +140,12 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
}
|
||||
|
||||
$acceptEditorPositionData(data: ITextEditorPositionData): void {
|
||||
for (let id in data) {
|
||||
let textEditor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
let viewColumn = TypeConverters.ViewColumn.to(data[id]);
|
||||
for (const id in data) {
|
||||
const textEditor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
if (!textEditor) {
|
||||
throw new Error('Unknown text editor');
|
||||
}
|
||||
const viewColumn = TypeConverters.ViewColumn.to(data[id]);
|
||||
if (textEditor.viewColumn !== viewColumn) {
|
||||
textEditor._acceptViewColumn(viewColumn);
|
||||
this._onDidChangeTextEditorViewColumn.fire({ textEditor, viewColumn });
|
||||
|
||||
@@ -366,7 +366,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
private getHandlesToRefresh(elements: T[]): TreeItemHandle[] {
|
||||
const elementsToUpdate = new Set<TreeItemHandle>();
|
||||
for (const element of elements) {
|
||||
let elementNode = this.nodes.get(element);
|
||||
const elementNode = this.nodes.get(element);
|
||||
if (elementNode && !elementsToUpdate.has(elementNode.item.handle)) {
|
||||
// check if an ancestor of extElement is already in the elements to update list
|
||||
let currentNode = elementNode;
|
||||
@@ -384,7 +384,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
// Take only top level elements
|
||||
elementsToUpdate.forEach((handle) => {
|
||||
const element = this.elements.get(handle);
|
||||
let node = this.nodes.get(element);
|
||||
const node = this.nodes.get(element);
|
||||
if (node && (!node.parent || !elementsToUpdate.has(node.parent.item.handle))) {
|
||||
handlesToUpdate.push(handle);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
|
||||
private clearChildren(parentElement?: T): void {
|
||||
if (parentElement) {
|
||||
let node = this.nodes.get(parentElement);
|
||||
const node = this.nodes.get(parentElement);
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
const childEleement = this.elements.get(child.item.handle);
|
||||
@@ -569,7 +569,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
}
|
||||
|
||||
private clear(element: T): void {
|
||||
let node = this.nodes.get(element);
|
||||
const node = this.nodes.get(element);
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
const childEleement = this.elements.get(child.item.handle);
|
||||
|
||||
@@ -236,7 +236,7 @@ export namespace MarkdownString {
|
||||
const resUris: { [href: string]: UriComponents } = Object.create(null);
|
||||
res.uris = resUris;
|
||||
|
||||
let renderer = new marked.Renderer();
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.image = renderer.link = (href: string): string => {
|
||||
try {
|
||||
let uri = URI.parse(href, true);
|
||||
@@ -267,7 +267,7 @@ export namespace MarkdownString {
|
||||
}
|
||||
data = cloneAndChange(data, value => {
|
||||
if (value instanceof URI) {
|
||||
let key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
|
||||
const key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
|
||||
bucket[key] = value;
|
||||
return key;
|
||||
} else {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class Position {
|
||||
}
|
||||
let result = positions[0];
|
||||
for (let i = 1; i < positions.length; i++) {
|
||||
let p = positions[i];
|
||||
const p = positions[i];
|
||||
if (p.isBefore(result!)) {
|
||||
result = p;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ export class Position {
|
||||
}
|
||||
let result = positions[0];
|
||||
for (let i = 1; i < positions.length; i++) {
|
||||
let p = positions[i];
|
||||
const p = positions[i];
|
||||
if (p.isAfter(result!)) {
|
||||
result = p;
|
||||
}
|
||||
@@ -303,8 +303,8 @@ export class Range {
|
||||
}
|
||||
|
||||
intersection(other: Range): Range | undefined {
|
||||
let start = Position.Max(other.start, this._start);
|
||||
let end = Position.Min(other.end, this._end);
|
||||
const start = Position.Max(other.start, this._start);
|
||||
const end = Position.Min(other.end, this._end);
|
||||
if (start.isAfter(end)) {
|
||||
// this happens when there is no overlap:
|
||||
// |-----|
|
||||
@@ -320,8 +320,8 @@ export class Range {
|
||||
} else if (other.contains(this)) {
|
||||
return other;
|
||||
}
|
||||
let start = Position.Min(other.start, this._start);
|
||||
let end = Position.Max(other.end, this.end);
|
||||
const start = Position.Min(other.start, this._start);
|
||||
const end = Position.Max(other.end, this.end);
|
||||
return new Range(start, end);
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ export class TextEdit {
|
||||
}
|
||||
|
||||
static setEndOfLine(eol: EndOfLine): TextEdit {
|
||||
let ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
||||
const ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
||||
ret.newEol = eol;
|
||||
return ret;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
get(uri: URI): TextEdit[] {
|
||||
let res: TextEdit[] = [];
|
||||
const res: TextEdit[] = [];
|
||||
for (let candidate of this._edits) {
|
||||
if (candidate._type === 2 && candidate.uri.toString() === uri.toString()) {
|
||||
res.push(candidate.edit);
|
||||
@@ -626,7 +626,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
entries(): [URI, TextEdit[]][] {
|
||||
let textEdits = new Map<string, [URI, TextEdit[]]>();
|
||||
const textEdits = new Map<string, [URI, TextEdit[]]>();
|
||||
for (let candidate of this._edits) {
|
||||
if (candidate._type === 2) {
|
||||
let textEdit = textEdits.get(candidate.uri.toString());
|
||||
@@ -641,7 +641,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
_allEntries(): ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] {
|
||||
let res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
|
||||
const res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
|
||||
for (let edit of this._edits) {
|
||||
if (edit._type === 1) {
|
||||
res.push([edit.from, edit.to, edit.options]);
|
||||
@@ -1883,7 +1883,7 @@ export class Task implements vscode.Task2 {
|
||||
}
|
||||
this.clear();
|
||||
this._execution = value;
|
||||
let type = this._definition.type;
|
||||
const type = this._definition.type;
|
||||
if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type || Task.ExtensionCallbackType === type) {
|
||||
this.computeDefinitionBasedOnExecution();
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
||||
}
|
||||
}
|
||||
|
||||
let excludePatternOrDisregardExcludes: string | false = false;
|
||||
let excludePatternOrDisregardExcludes: string | false | undefined = undefined;
|
||||
if (exclude === null) {
|
||||
excludePatternOrDisregardExcludes = false;
|
||||
} else if (exclude) {
|
||||
@@ -459,7 +459,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
||||
excludePattern: options.exclude ? globPatternToString(options.exclude) : undefined
|
||||
};
|
||||
|
||||
let isCanceled = false;
|
||||
const isCanceled = false;
|
||||
|
||||
this._activeSearchCallbacks[requestId] = p => {
|
||||
if (isCanceled) {
|
||||
|
||||
Reference in New Issue
Block a user