diff --git a/languageServer/src/LanguageServer.ts b/languageServer/src/LanguageServer.ts index 9a0da1e348..fd1e2ad598 100644 --- a/languageServer/src/LanguageServer.ts +++ b/languageServer/src/LanguageServer.ts @@ -107,7 +107,7 @@ export class LanguageServer { ) { for (const possibleFile of symbolUnderCursor.name.split(' ')) { const possiblePath = URI.parse( - join(dirname(document.uri), possibleFile) + join(dirname(document.uri), ...possibleFile.split('/')) ).toString() const file = await connection.sendRequest<{ contents: string diff --git a/languageServer/src/test/definitions.test.ts b/languageServer/src/test/definitions.test.ts index 01fa45cd1a..eebe6cb9d7 100644 --- a/languageServer/src/test/definitions.test.ts +++ b/languageServer/src/test/definitions.test.ts @@ -1,3 +1,4 @@ +import { join } from 'path' import { Position, Range } from 'vscode-languageserver/node' import { URI } from 'vscode-uri' import { params_dvc_yaml, train_dvc_yaml } from './fixtures/examples/valid' @@ -59,7 +60,7 @@ describe('textDocument/definitions', () => { }) it('should try to read the file system when a python file is unknown', async () => { - const trainUri = URI.file('train.py').toString() + const trainUri = URI.file(join(__dirname, 'train.py')).toString() mockedReadFileContents.mockImplementation(path => { if (path === trainUri) { @@ -72,7 +73,7 @@ describe('textDocument/definitions', () => { { languageId: 'yaml', mockContents: train_dvc_yaml, - mockPath: 'dvc.yaml' + mockPath: join(__dirname, 'dvc.yaml') } ]) diff --git a/languageServer/src/test/utils/openTheseFilesAndNotifyServer.ts b/languageServer/src/test/utils/openTheseFilesAndNotifyServer.ts index 1134ca0d12..7ae49968bb 100644 --- a/languageServer/src/test/utils/openTheseFilesAndNotifyServer.ts +++ b/languageServer/src/test/utils/openTheseFilesAndNotifyServer.ts @@ -4,7 +4,7 @@ import { URI } from 'vscode-uri' import { client } from './setup-test-connections' export const openTheseFilesAndNotifyServer = async ( - files: Array<{ mockPath: string; mockContents: string; languageId: string }> + files: { mockPath: string; mockContents: string; languageId: string }[] ) => { const filesToReturn: TextDocument[] = []