From 0a9f00577360879fea28a43aea8156c61d0384dd Mon Sep 17 00:00:00 2001 From: idillon Date: Fri, 24 Nov 2023 13:22:18 -0500 Subject: [PATCH] Fix: Hover for Python functions that are Yocto tasks --- client/src/language/middlewareHover.ts | 6 +++++- .../project-folder/sources/meta-fixtures/hover.bb | 6 ++++++ integration-tests/src/tests/hover.test.ts | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client/src/language/middlewareHover.ts b/client/src/language/middlewareHover.ts index e237383f..7852800a 100644 --- a/client/src/language/middlewareHover.ts +++ b/client/src/language/middlewareHover.ts @@ -11,9 +11,13 @@ import { getEmbeddedLanguageDocPosition } from './utils' import { getFileContent } from '../lib/src/utils/files' export const middlewareProvideHover: HoverMiddleware['provideHover'] = async (document, position, token, next) => { + const nextResult = await next(document, position, token) + if (nextResult !== undefined) { + return nextResult + } const embeddedLanguageDocInfos = await requestsManager.getEmbeddedLanguageDocInfos(document.uri.toString(), position) if (embeddedLanguageDocInfos === undefined || embeddedLanguageDocInfos === null) { - return await next(document, position, token) + return } const embeddedLanguageDocContent = await getFileContent(Uri.parse(embeddedLanguageDocInfos.uri).fsPath) if (embeddedLanguageDocContent === undefined) { diff --git a/integration-tests/project-folder/sources/meta-fixtures/hover.bb b/integration-tests/project-folder/sources/meta-fixtures/hover.bb index b0cbc997..cb257b96 100644 --- a/integration-tests/project-folder/sources/meta-fixtures/hover.bb +++ b/integration-tests/project-folder/sources/meta-fixtures/hover.bb @@ -7,3 +7,9 @@ python do_foo(){ do_bar(){ echo '123' } + +python do_build() { +} + +do_build() { +} \ No newline at end of file diff --git a/integration-tests/src/tests/hover.test.ts b/integration-tests/src/tests/hover.test.ts index deb6b937..16eac255 100644 --- a/integration-tests/src/tests/hover.test.ts +++ b/integration-tests/src/tests/hover.test.ts @@ -62,4 +62,16 @@ suite('Bitbake Hover Test Suite', () => { const expected = 'echo' await testHover(position, expected) }).timeout(300000) + + test('Hover shows task description on python function declaration', async () => { + const position = new vscode.Position(10, 9) + const expected = 'The default task for all recipes. This task depends on all other normal' + await testHover(position, expected) + }).timeout(300000) + + test('Hover shows task description on bash function declaration', async () => { + const position = new vscode.Position(13, 1) + const expected = 'The default task for all recipes. This task depends on all other normal' + await testHover(position, expected) + }).timeout(300000) })