diff --git a/src/vs/editor/contrib/hover/modesContentHover.ts b/src/vs/editor/contrib/hover/modesContentHover.ts index 7bc5a7fb022029036e0b109b844f0629de7f4f50..ee2c456fdfaa093591a9684cfa4b6142c8534898 100644 --- a/src/vs/editor/contrib/hover/modesContentHover.ts +++ b/src/vs/editor/contrib/hover/modesContentHover.ts @@ -70,6 +70,7 @@ class ModesContentComputer implements IHoverComputer { private readonly _markerDecorationsService: IMarkerDecorationsService ) { this._editor = editor; + this._result = []; } setRange(range: Range): void { diff --git a/src/vs/editor/contrib/hover/modesGlyphHover.ts b/src/vs/editor/contrib/hover/modesGlyphHover.ts index b2b78438a79503478aec6d527f5c82cff75d2f1e..85dece77b64b210a0bd931b69ceca277b869ade8 100644 --- a/src/vs/editor/contrib/hover/modesGlyphHover.ts +++ b/src/vs/editor/contrib/hover/modesGlyphHover.ts @@ -27,6 +27,7 @@ class MarginComputer implements IHoverComputer { constructor(editor: ICodeEditor) { this._editor = editor; this._lineNumber = -1; + this._result = []; } public setLineNumber(lineNumber: number): void { @@ -100,6 +101,7 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget { ) { super(ModesGlyphHoverWidget.ID, editor); + this._messages = []; this._lastLineNumber = -1; this._markdownRenderer = this._register(new MarkdownRenderer(this._editor, modeService, openerService)); diff --git a/src/vs/editor/contrib/indentation/indentation.ts b/src/vs/editor/contrib/indentation/indentation.ts index dc51d0faf452377d4dbd2d3cfd22c5a6731acabb..fd9fcee54ea498e5f38699eacdb39e4b39821f60 100644 --- a/src/vs/editor/contrib/indentation/indentation.ts +++ b/src/vs/editor/contrib/indentation/indentation.ts @@ -378,11 +378,12 @@ export class AutoIndentOnPasteCommand implements ICommand { private readonly _edits: { range: IRange; text: string; eol?: EndOfLineSequence; }[]; private readonly _initialSelection: Selection; - private _selectionId: string; + private _selectionId: string | null; constructor(edits: TextEdit[], initialSelection: Selection) { this._initialSelection = initialSelection; this._edits = []; + this._selectionId = null; for (let edit of edits) { if (edit.range && typeof edit.text === 'string') { @@ -415,7 +416,7 @@ export class AutoIndentOnPasteCommand implements ICommand { } public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection { - return helper.getTrackedSelection(this._selectionId); + return helper.getTrackedSelection(this._selectionId!); } } @@ -651,7 +652,7 @@ function getIndentationEditOperations(model: ITextModel, builder: IEditOperation export class IndentationToSpacesCommand implements ICommand { - private selectionId: string; + private selectionId: string | null = null; constructor(private readonly selection: Selection, private tabSize: number) { } @@ -661,13 +662,13 @@ export class IndentationToSpacesCommand implements ICommand { } public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection { - return helper.getTrackedSelection(this.selectionId); + return helper.getTrackedSelection(this.selectionId!); } } export class IndentationToTabsCommand implements ICommand { - private selectionId: string; + private selectionId: string | null = null; constructor(private readonly selection: Selection, private tabSize: number) { } @@ -677,7 +678,7 @@ export class IndentationToTabsCommand implements ICommand { } public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection { - return helper.getTrackedSelection(this.selectionId); + return helper.getTrackedSelection(this.selectionId!); } } @@ -688,4 +689,4 @@ registerEditorAction(IndentUsingTabs); registerEditorAction(IndentUsingSpaces); registerEditorAction(DetectIndentation); registerEditorAction(ReindentLinesAction); -registerEditorAction(ReindentSelectedLinesAction); \ No newline at end of file +registerEditorAction(ReindentSelectedLinesAction); diff --git a/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts b/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts index 799b61088f2a298d33b6410d87eaeaae4c713d35..3d2078200618625cbee620ac8a38149bdbd726da 100644 --- a/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts @@ -14,13 +14,17 @@ export class CopyLinesCommand implements editorCommon.ICommand { private readonly _isCopyingDown: boolean; private _selectionDirection: SelectionDirection; - private _selectionId: string; + private _selectionId: string | null; private _startLineNumberDelta: number; private _endLineNumberDelta: number; constructor(selection: Selection, isCopyingDown: boolean) { this._selection = selection; this._isCopyingDown = isCopyingDown; + this._selectionDirection = SelectionDirection.LTR; + this._selectionId = null; + this._startLineNumberDelta = 0; + this._endLineNumberDelta = 0; } public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void { @@ -58,7 +62,7 @@ export class CopyLinesCommand implements editorCommon.ICommand { } public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection { - let result = helper.getTrackedSelection(this._selectionId); + let result = helper.getTrackedSelection(this._selectionId!); if (this._startLineNumberDelta !== 0 || this._endLineNumberDelta !== 0) { let startLineNumber = result.startLineNumber; diff --git a/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts b/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts index 1053f758bdd8ad8ad17c0c7dd743d19e1a51ab44..f1b0fd7befb506ce9642c1f9c08163d09a7b42e0 100644 --- a/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts @@ -20,7 +20,7 @@ export class MoveLinesCommand implements ICommand { private readonly _isMovingDown: boolean; private readonly _autoIndent: boolean; - private _selectionId: string; + private _selectionId: string | null; private _moveEndPositionDown?: boolean; private _moveEndLineSelectionShrink: boolean; @@ -28,6 +28,7 @@ export class MoveLinesCommand implements ICommand { this._selection = selection; this._isMovingDown = isMovingDown; this._autoIndent = autoIndent; + this._selectionId = null; this._moveEndLineSelectionShrink = false; } @@ -36,9 +37,11 @@ export class MoveLinesCommand implements ICommand { let modelLineCount = model.getLineCount(); if (this._isMovingDown && this._selection.endLineNumber === modelLineCount) { + this._selectionId = builder.trackSelection(this._selection); return; } if (!this._isMovingDown && this._selection.startLineNumber === 1) { + this._selectionId = builder.trackSelection(this._selection); return; } @@ -328,7 +331,7 @@ export class MoveLinesCommand implements ICommand { } public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection { - let result = helper.getTrackedSelection(this._selectionId); + let result = helper.getTrackedSelection(this._selectionId!); if (this._moveEndPositionDown) { result = result.setEndPosition(result.endLineNumber + 1, 1); diff --git a/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts b/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts index 304084db5f2af6347cd59a854862bc4ea5d48dda..6c52081947ca57994c90edbb1f61d80e9668436d 100644 --- a/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts @@ -12,12 +12,13 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod export class SortLinesCommand implements editorCommon.ICommand { private readonly selection: Selection; - private selectionId: string; private readonly descending: boolean; + private selectionId: string | null; constructor(selection: Selection, descending: boolean) { this.selection = selection; this.descending = descending; + this.selectionId = null; } public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void { @@ -30,7 +31,7 @@ export class SortLinesCommand implements editorCommon.ICommand { } public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection { - return helper.getTrackedSelection(this.selectionId); + return helper.getTrackedSelection(this.selectionId!); } public static canRun(model: ITextModel | null, selection: Selection, descending: boolean): boolean { diff --git a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts index 0820b22ce51a045bbc138de160de9a9abbb18b65..4fd4f5d2db069458a22083633f766e130312b172 100644 --- a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts @@ -469,6 +469,7 @@ class WordHighlighterContribution extends Disposable implements editorCommon.IEd constructor(editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService) { super(); + this.wordHighligher = null; const createWordHighlighterIfPossible = () => { if (editor.hasModel()) { this.wordHighligher = new WordHighlighter(editor, contextKeyService); diff --git a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts index 1fc21b5fc7fd0111a139fe83ede19020fb995e1b..b36f6ecdc23bb12add6c02a2a589fc1709ec2017 100644 --- a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts +++ b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts @@ -21,6 +21,7 @@ export class IPadShowKeyboard extends Disposable implements IEditorContribution constructor(editor: ICodeEditor) { super(); this.editor = editor; + this.widget = null; if (browser.isIPad) { this._register(editor.onDidChangeConfiguration(() => this.update())); this.update(); diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 423b8497be7f36bc1a7128bdb5767e8947148e47..54804eb3c0f9364c484b758dfe7b2fae3b9a5d47 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -98,17 +98,20 @@ function withTypedEditor(widget: editorCommon.IEditor, codeEditorCallback: (e export class SimpleEditorModelResolverService implements ITextModelService { public _serviceBrand: any; - private editor: editorCommon.IEditor; + private editor?: editorCommon.IEditor; public setEditor(editor: editorCommon.IEditor): void { this.editor = editor; } public createModelReference(resource: URI): Promise> { - let model: ITextModel | null = withTypedEditor(this.editor, - (editor) => this.findModel(editor, resource), - (diffEditor) => this.findModel(diffEditor.getOriginalEditor(), resource) || this.findModel(diffEditor.getModifiedEditor(), resource) - ); + let model: ITextModel | null = null; + if (this.editor) { + model = withTypedEditor(this.editor, + (editor) => this.findModel(editor, resource), + (diffEditor) => this.findModel(diffEditor.getOriginalEditor(), resource) || this.findModel(diffEditor.getModifiedEditor(), resource) + ); + } if (!model) { return Promise.reject(new Error(`Model not found`)); @@ -477,12 +480,12 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur _serviceBrand: any; - public readonly onDidChangeConfiguration: Event; - private readonly _onDidChangeConfigurationEmitter = new Emitter(); + private readonly _onDidChangeConfiguration = new Emitter(); + public readonly onDidChangeConfiguration = this._onDidChangeConfiguration.event; constructor(private readonly configurationService: SimpleConfigurationService) { this.configurationService.onDidChangeConfiguration((e) => { - this._onDidChangeConfigurationEmitter.fire(e); + this._onDidChangeConfiguration.fire(e); }); } @@ -519,7 +522,7 @@ export class SimpleResourcePropertiesService implements ITextResourcePropertiesS } export class StandaloneTelemetryService implements ITelemetryService { - _serviceBrand: void; + _serviceBrand: void = undefined; public isOptedIn = false; @@ -687,7 +690,7 @@ export class SimpleLayoutService implements ILayoutService { public onLayout = Event.None; - private _dimension: IDimension; + private _dimension?: IDimension; get dimension(): IDimension { if (!this._dimension) { this._dimension = dom.getClientArea(window.document.body); diff --git a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts index 85b3aaaf0cf08cbd1ae1298db74e640f70e6c504..7a00d9f2291970ec9127c2ec9b036ab38229b13a 100644 --- a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts @@ -176,9 +176,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon ); super(domElement, options, {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService); - if (keybindingService instanceof StandaloneKeybindingService) { - this._standaloneKeybindingService = keybindingService; - } + this._standaloneKeybindingService = keybindingService; // Create the ARIA dom node as soon as the first editor is instantiated createAriaDomNode(); diff --git a/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts b/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts index 3f04994e55ce08578a3425b645adbc9e44701729..2a47cc6113b4b96ce31bf57c86fadcad01dc3234 100644 --- a/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts +++ b/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts @@ -160,7 +160,7 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService { private readonly _knownThemes: Map; private readonly _styleElement: HTMLStyleElement; - private _theme: IStandaloneTheme; + private _theme!: IStandaloneTheme; private readonly _onThemeChange: Emitter; private readonly _onIconThemeChange: Emitter; private readonly environment: IEnvironmentService = Object.create(null); diff --git a/src/vs/platform/remote/common/remoteAgentFileSystemChannel.ts b/src/vs/platform/remote/common/remoteAgentFileSystemChannel.ts index cefb3518ba0b27263c8ad02cdf64d6123a436005..1f8b5fee33ca5046d1f742f9b76afa3faf241638 100644 --- a/src/vs/platform/remote/common/remoteAgentFileSystemChannel.ts +++ b/src/vs/platform/remote/common/remoteAgentFileSystemChannel.ts @@ -33,7 +33,7 @@ export class RemoteExtensionsFileSystemProvider extends Disposable implements IF private readonly _onDidChangeCapabilities = this._register(new Emitter()); readonly onDidChangeCapabilities: Event = this._onDidChangeCapabilities.event; - private _capabilities: FileSystemProviderCapabilities; + private _capabilities!: FileSystemProviderCapabilities; get capabilities(): FileSystemProviderCapabilities { return this._capabilities; } constructor(private readonly channel: IChannel, environment: Promise) { diff --git a/src/vs/workbench/api/node/extHostRequireInterceptor.ts b/src/vs/workbench/api/node/extHostRequireInterceptor.ts index 789ece36253b6c07a82eba421f2adb3ac184ad31..8633dc023bc223a4c87c74e43776e531c9e79f33 100644 --- a/src/vs/workbench/api/node/extHostRequireInterceptor.ts +++ b/src/vs/workbench/api/node/extHostRequireInterceptor.ts @@ -75,7 +75,7 @@ export class VSCodeNodeModuleFactory implements INodeModuleFactory { public readonly nodeModuleName = 'vscode'; private readonly _extApiImpl = new Map(); - private _defaultApiImpl: typeof vscode; + private _defaultApiImpl?: typeof vscode; constructor( private readonly _apiFactory: IExtensionApiFactory, @@ -191,7 +191,7 @@ export class OpenNodeModuleFactory implements INodeModuleFactory { public readonly nodeModuleName: string[] = ['open', 'opn']; private _extensionId: string | undefined; - private _original: IOriginalOpen; + private _original?: IOriginalOpen; private _impl: IOpenModule; constructor(mainThreadWindow: MainThreadWindowShape, private _mainThreadTelemerty: MainThreadTelemetryShape, private readonly _extensionPaths: TernarySearchTree) { @@ -224,7 +224,7 @@ export class OpenNodeModuleFactory implements INodeModuleFactory { private callOriginal(target: string, options: OpenOptions | undefined): Thenable { this.sendNoForwardTelemetry(); - return this._original(target, options); + return this._original!(target, options); } private sendShimmingTelemetry(): void { diff --git a/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.ts b/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.ts index 0c3523f555e3ab7a85a3b618b238edcaf3cd03d8..38c4b63eda7c9e2ca5c73ce7942db25c428f9704 100644 --- a/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.ts +++ b/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.ts @@ -17,9 +17,9 @@ export class ExtensionDescriptionRegistry { public readonly onDidChange = this._onDidChange.event; private _extensionDescriptions: IExtensionDescription[]; - private _extensionsMap: Map; - private _extensionsArr: IExtensionDescription[]; - private _activationMap: Map; + private _extensionsMap!: Map; + private _extensionsArr!: IExtensionDescription[]; + private _activationMap!: Map; constructor(extensionDescriptions: IExtensionDescription[]) { this._extensionDescriptions = extensionDescriptions; diff --git a/src/vs/workbench/services/extensions/common/proxyIdentifier.ts b/src/vs/workbench/services/extensions/common/proxyIdentifier.ts index fdf7d366c94e612eda432dd9f48e4c5616a733dc..311d9e7cd07c598ff03f444a93a0d904fcf45afe 100644 --- a/src/vs/workbench/services/extensions/common/proxyIdentifier.ts +++ b/src/vs/workbench/services/extensions/common/proxyIdentifier.ts @@ -20,10 +20,10 @@ export interface IRPCProtocol { assertRegistered(identifiers: ProxyIdentifier[]): void; } +// @ts-ignore export class ProxyIdentifier { public static count = 0; _proxyIdentifierBrand: void; - _suppressCompilerUnusedWarning: T; public readonly isMain: boolean; public readonly sid: string; diff --git a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts index 10fd66cbdc91ac47d89dc65aa053d0cb802fd458..5558123d19a68bc266ffbb19d9021c254177a611 100644 --- a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts +++ b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts @@ -48,8 +48,8 @@ function getExtraDevSystemExtensionsRoot(): string { export class CachedExtensionScanner { public readonly scannedExtensions: Promise; - private _scannedExtensionsResolve: (result: IExtensionDescription[]) => void; - private _scannedExtensionsReject: (err: any) => void; + private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void; + private _scannedExtensionsReject!: (err: any) => void; public readonly translationConfig: Promise; constructor( diff --git a/src/vs/workbench/services/extensions/node/extensionPoints.ts b/src/vs/workbench/services/extensions/node/extensionPoints.ts index 5a7efd1462bd6436be9a782c5cf199d7374d4951..f20f824a2e2c9e3deca617d551cc5122eb43006e 100644 --- a/src/vs/workbench/services/extensions/node/extensionPoints.ts +++ b/src/vs/workbench/services/extensions/node/extensionPoints.ts @@ -409,7 +409,7 @@ class ExtensionManifestValidator extends ExtensionManifestHandler { export class ExtensionScannerInput { - public mtime: number; + public mtime: number | undefined; constructor( public readonly ourVersion: string, @@ -609,4 +609,4 @@ export class ExtensionScanner { return resultArr; }); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts b/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts index cf1658b05c5592c9796c25eb2710a519590c47f0..6e0669eb0d24df0d2e6f267cd7ab7dec522309da 100644 --- a/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts +++ b/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts @@ -14,7 +14,7 @@ import { VSBuffer } from 'vs/base/common/buffer'; suite('RPCProtocol', () => { class MessagePassingProtocol implements IMessagePassingProtocol { - private _pair: MessagePassingProtocol; + private _pair?: MessagePassingProtocol; private readonly _onMessage = new Emitter(); public readonly onMessage: Event = this._onMessage.event; @@ -25,7 +25,7 @@ suite('RPCProtocol', () => { public send(buffer: VSBuffer): void { process.nextTick(() => { - this._pair._onMessage.fire(buffer); + this._pair!._onMessage.fire(buffer); }); } } diff --git a/src/vs/workbench/services/remote/common/abstractRemoteAgentService.ts b/src/vs/workbench/services/remote/common/abstractRemoteAgentService.ts index 5168e7f16c39e6054d250de654807d105bc2e114..3a789e23d9855f4492ef258eb950e0420bf6b6d7 100644 --- a/src/vs/workbench/services/remote/common/abstractRemoteAgentService.ts +++ b/src/vs/workbench/services/remote/common/abstractRemoteAgentService.ts @@ -31,6 +31,7 @@ export abstract class AbstractRemoteAgentService extends Disposable { @IEnvironmentService protected readonly _environmentService: IEnvironmentService ) { super(); + this._environment = null; } abstract getConnection(): IRemoteAgentConnection | null; diff --git a/src/vs/workbench/services/textMate/common/TMScopeRegistry.ts b/src/vs/workbench/services/textMate/common/TMScopeRegistry.ts index 4c352da67a479aeb874aff6eacf29c0c92204917..4c6d3c5fdb7eaaa2153426596ad63963c53abdd3 100644 --- a/src/vs/workbench/services/textMate/common/TMScopeRegistry.ts +++ b/src/vs/workbench/services/textMate/common/TMScopeRegistry.ts @@ -31,7 +31,7 @@ export class TMScopeRegistry extends Disposable { constructor() { super(); - this.reset(); + this._scopeNameToLanguageRegistration = Object.create(null); } public reset(): void { diff --git a/src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts b/src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts index a5c24f1d7f7d8448c5dc240c7114dfcaa1367d91..6f78679f1fd5a83230b21c28bda696965587f8c2 100644 --- a/src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts +++ b/src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts @@ -80,7 +80,7 @@ class TextMateWorkerModel extends MirrorTextModel { const languageId = this._languageId; this._worker.getOrCreateGrammar(languageId).then((r) => { - if (this._isDisposed || languageId !== this._languageId) { + if (this._isDisposed || languageId !== this._languageId || !r) { return; } @@ -118,7 +118,7 @@ export class TextMateWorker { private readonly _host: TextMateWorkerHost; private readonly _models: { [uri: string]: TextMateWorkerModel; }; private readonly _grammarCache: Promise[]; - private readonly _grammarFactory: TMGrammarFactory; + private readonly _grammarFactory: TMGrammarFactory | null; constructor(ctx: IWorkerContext, createData: ICreateData) { this._host = ctx.host; @@ -135,23 +135,23 @@ export class TextMateWorker { }; }); - let vscodeTextmate: typeof import('vscode-textmate'); const globalDefine = (self).define; try { (self).define.amd = undefined; - vscodeTextmate = require.__$__nodeRequire('vscode-textmate'); + const vscodeTextmate = require.__$__nodeRequire('vscode-textmate'); + + this._grammarFactory = new TMGrammarFactory({ + logTrace: (msg: string) => {/* console.log(msg) */ }, + logError: (msg: string, err: any) => console.error(msg, err), + readFile: (resource: URI) => this._host.readFile(resource) + }, grammarDefinitions, vscodeTextmate, undefined); } catch (err) { console.error(err); + this._grammarFactory = null; return; } finally { (self).define = globalDefine; } - - this._grammarFactory = new TMGrammarFactory({ - logTrace: (msg: string) => {/* console.log(msg) */ }, - logError: (msg: string, err: any) => console.error(msg, err), - readFile: (resource: URI) => this._host.readFile(resource) - }, grammarDefinitions, vscodeTextmate, undefined); } public acceptNewModel(data: IRawModelData): void { @@ -175,7 +175,10 @@ export class TextMateWorker { } } - public getOrCreateGrammar(languageId: LanguageId): Promise { + public getOrCreateGrammar(languageId: LanguageId): Promise { + if (!this._grammarFactory) { + return Promise.resolve(null); + } if (!this._grammarCache[languageId]) { this._grammarCache[languageId] = this._grammarFactory.createGrammar(languageId); } @@ -183,7 +186,9 @@ export class TextMateWorker { } public acceptTheme(theme: IRawTheme): void { - this._grammarFactory.setTheme(theme); + if (this._grammarFactory) { + this._grammarFactory.setTheme(theme); + } } public _setTokens(resource: URI, versionId: number, tokens: Uint8Array): void { diff --git a/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts b/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts index 9391351cdaefd6451763f44572f07601e474dac0..64fa203834f3a85413dce50eb625cd4f0e778e36 100644 --- a/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts +++ b/src/vs/workbench/test/electron-browser/api/testRPCProtocol.ts @@ -27,7 +27,7 @@ export class TestRPCProtocol implements IExtHostContext { private _callCountValue: number = 0; private _idle?: Promise; - private _completeIdle: Function; + private _completeIdle?: Function; private readonly _locals: { [id: string]: any; }; private readonly _proxies: { [id: string]: any; };