From e9f395cbf0b63ff4c8b585f8170b70e06f0a9314 Mon Sep 17 00:00:00 2001 From: Wolmir Nemitz Date: Mon, 3 Oct 2022 13:04:34 -0300 Subject: [PATCH] Fix Goto definition for file paths --- languageServer/src/LanguageServer.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/languageServer/src/LanguageServer.ts b/languageServer/src/LanguageServer.ts index b861a2d8d0..a3bc86af7f 100644 --- a/languageServer/src/LanguageServer.ts +++ b/languageServer/src/LanguageServer.ts @@ -61,15 +61,30 @@ export class LanguageServer { return new TextDocumentWrapper(doc) } + private isPossibleFilePath(symbol: DocumentSymbol) { + const isFile = symbol.kind === SymbolKind.File + const isProperty = symbol.kind === SymbolKind.Property + + return isFile || (symbol.detail && isProperty) + } + + private getFilePathFromSymbol(symbol: DocumentSymbol) { + if (symbol.kind === SymbolKind.File) { + return symbol.name + } + + return symbol.detail ?? '' + } + private getFilePathLocations( symbolUnderCursor: DocumentSymbol, allDocs: TextDocumentWrapper[] ) { - if (symbolUnderCursor.kind !== SymbolKind.File) { + if (!this.isPossibleFilePath(symbolUnderCursor)) { return [] } - const filePath = symbolUnderCursor.name + const filePath = this.getFilePathFromSymbol(symbolUnderCursor) const matchingFiles = allDocs.filter(doc => URI.file(doc.uri).fsPath.endsWith(filePath)