From f4953e52f161f204803985a274723fa56a6e6bab Mon Sep 17 00:00:00 2001 From: idillon Date: Mon, 13 Nov 2023 17:50:07 -0500 Subject: [PATCH] Fix: Middlewares also expect null regions --- client/src/language/middlewareCompletion.ts | 2 +- client/src/language/middlewareHover.ts | 2 +- client/src/lib/src/types/requests.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/language/middlewareCompletion.ts b/client/src/language/middlewareCompletion.ts index 1f63bbbf..fa4d768a 100644 --- a/client/src/language/middlewareCompletion.ts +++ b/client/src/language/middlewareCompletion.ts @@ -11,7 +11,7 @@ import { getEmbeddedLanguageDocPosition } from './utils' export const middlewareProvideCompletion: CompletionMiddleware['provideCompletionItem'] = async (document, position, context, token, next) => { const embeddedLanguageDocInfos = await requestsManager.getEmbeddedLanguageDocInfos(document.uri.toString(), position) - if (embeddedLanguageDocInfos === undefined) { + if (embeddedLanguageDocInfos === undefined || embeddedLanguageDocInfos === null) { return await next(document, position, context, token) } const adjustedPosition = await getEmbeddedLanguageDocPosition(document, embeddedLanguageDocInfos, position) diff --git a/client/src/language/middlewareHover.ts b/client/src/language/middlewareHover.ts index ccb94ed9..51d21fe5 100644 --- a/client/src/language/middlewareHover.ts +++ b/client/src/language/middlewareHover.ts @@ -11,7 +11,7 @@ import { getEmbeddedLanguageDocPosition } from './utils' export const middlewareProvideHover: HoverMiddleware['provideHover'] = async (document, position, token, next) => { const embeddedLanguageDocInfos = await requestsManager.getEmbeddedLanguageDocInfos(document.uri.toString(), position) - if (embeddedLanguageDocInfos === undefined) { + if (embeddedLanguageDocInfos === undefined || embeddedLanguageDocInfos === null) { return await next(document, position, token) } const adjustedPosition = await getEmbeddedLanguageDocPosition(document, embeddedLanguageDocInfos, position) diff --git a/client/src/lib/src/types/requests.ts b/client/src/lib/src/types/requests.ts index 8c5f39ce..731de414 100644 --- a/client/src/lib/src/types/requests.ts +++ b/client/src/lib/src/types/requests.ts @@ -19,7 +19,7 @@ export interface RequestParams { } export interface RequestResult { - [RequestType.EmbeddedLanguageDocInfos]: Promise + [RequestType.EmbeddedLanguageDocInfos]: Promise // for unknown reasons, the client receives null instead of undefined } interface RequestEmbeddedLanguageDocInfosParams {