From e0c11b34f5f1962fa92c8aff02dbde98d072b412 Mon Sep 17 00:00:00 2001 From: paranoidjk Date: Fri, 14 May 2021 21:40:44 +0800 Subject: [PATCH] fix: support go to definition for extraLib file --- src/languageFeatures.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/languageFeatures.ts b/src/languageFeatures.ts index d54c7a1a..e7fe97a9 100644 --- a/src/languageFeatures.ts +++ b/src/languageFeatures.ts @@ -7,7 +7,8 @@ import { Diagnostic, DiagnosticRelatedInformation, - LanguageServiceDefaults + LanguageServiceDefaults, + typescriptDefaults } from './monaco.contribution'; import type * as ts from './lib/typescriptServices'; import type { TypeScriptWorker } from './tsWorker'; @@ -789,6 +790,17 @@ export class DefinitionAdapter extends Adapter { uri: uri, range: this._textSpanToRange(refModel, entry.textSpan) }); + } else { + const matchedLibFile = typescriptDefaults.getExtraLibs()[entry.fileName] + if (matchedLibFile) { + const libModel = editor.createModel(matchedLibFile.content, 'typescript', uri); + return { + uri: uri, + range: this._textSpanToRange(libModel, entry.textSpan) + } + } + + } } return result;