mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
70 lines
2.9 KiB
TypeScript
70 lines
2.9 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService';
|
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
|
import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService';
|
|
import { IOnigLib } from 'vscode-textmate';
|
|
import { IModeService } from 'vs/editor/common/services/modeService';
|
|
import { ILogService } from 'vs/platform/log/common/log';
|
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
|
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
import { IStorageService } from 'vs/platform/storage/common/storage';
|
|
import { IExtensionResourceLoaderService } from 'vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader';
|
|
|
|
export class TextMateService extends AbstractTextMateService {
|
|
|
|
constructor(
|
|
@IModeService modeService: IModeService,
|
|
@IWorkbenchThemeService themeService: IWorkbenchThemeService,
|
|
@IExtensionResourceLoaderService extensionResourceLoaderService: IExtensionResourceLoaderService,
|
|
@INotificationService notificationService: INotificationService,
|
|
@ILogService logService: ILogService,
|
|
@IConfigurationService configurationService: IConfigurationService,
|
|
@IStorageService storageService: IStorageService
|
|
) {
|
|
super(modeService, themeService, extensionResourceLoaderService, notificationService, logService, configurationService, storageService);
|
|
}
|
|
|
|
protected _loadVSCodeTextmate(): Promise<typeof import('vscode-textmate')> {
|
|
return import('vscode-textmate');
|
|
}
|
|
|
|
protected _loadOnigLib(): Promise<IOnigLib> | undefined {
|
|
return loadOnigasm();
|
|
}
|
|
}
|
|
|
|
let onigasmPromise: Promise<IOnigLib> | null = null;
|
|
async function loadOnigasm(): Promise<IOnigLib> {
|
|
if (!onigasmPromise) {
|
|
onigasmPromise = doLoadOnigasm();
|
|
}
|
|
return onigasmPromise;
|
|
}
|
|
|
|
async function doLoadOnigasm(): Promise<IOnigLib> {
|
|
const [wasmBytes, onigasm] = await Promise.all([
|
|
loadOnigasmWASM(),
|
|
import('onigasm-umd')
|
|
]);
|
|
|
|
await onigasm.loadWASM(wasmBytes);
|
|
return {
|
|
createOnigScanner(patterns: string[]) { return new onigasm.OnigScanner(patterns); },
|
|
createOnigString(s: string) { return new onigasm.OnigString(s); }
|
|
};
|
|
}
|
|
|
|
async function loadOnigasmWASM(): Promise<ArrayBuffer> {
|
|
const wasmPath = require.toUrl('onigasm-umd/../onigasm.wasm');
|
|
const response = await fetch(wasmPath);
|
|
const bytes = await response.arrayBuffer();
|
|
return bytes;
|
|
}
|
|
|
|
registerSingleton(ITextMateService, TextMateService);
|