Skip to content

Commit

Permalink
Fix Goto definition for file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
wolmir committed Oct 3, 2022
1 parent 8ba8236 commit e9f395c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions languageServer/src/LanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9f395c

Please sign in to comment.