fix(language-server): gate api hover to actual api.<name> references
Quality / quality (ubuntu-latest) (push) Failing after 9m55s
Quality / quality (windows-latest) (push) Canceled after 0s

Hover fired on whatever word was under the cursor, so a local variable
colliding with a declared block name reported the block's method and path
instead of its own hover info. Completion was already gated this way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 19:03:46 +05:30
co-authored by Claude Opus 5
parent e944fd4496
commit 5429057a38
4 changed files with 57 additions and 5 deletions
+9 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env node
// WRN editor language server source hash: eca7e58f47277a649cf9f7b2fcf23d2db52c18ff64e3f3ffb0b442d9d5f2024d
// WRN editor language server source hash: 1efd569f289f736d7dc094e4165d11490593f1c4534ae460a5122bf6dd45344b
// WRN editor language server generator hash: f593a44aaf05495b789ce7a3086bee1eebb951b884d41c0e017bbcfe5f547e72
// @bun @bun-cjs
(function(exports, require, module, __filename, __dirname) {var __create = Object.create;
@@ -169658,6 +169658,7 @@ var require_main = __commonJS((exports2, module2) => {
// packages/language-server/src/server.ts
var exports_server = {};
__export(exports_server, {
isApiReferenceAt: () => isApiReferenceAt,
apiCallHover: () => apiCallHover,
apiCallCompletions: () => apiCallCompletions
});
@@ -196268,6 +196269,12 @@ function isApiCallPosition(text, offset) {
const before = text.slice(0, offset);
return /\bapi\.\w*$/.test(before);
}
function isApiReferenceAt(text, offset) {
let start = offset;
while (start > 0 && /\w/.test(text[start - 1]))
start--;
return /\bapi\.$/.test(text.slice(0, start));
}
var documents = new Map;
var diagnosticTimers = new Map;
var MAX_OPEN_DOCUMENTS = 256;
@@ -196466,7 +196473,7 @@ async function handle(message) {
case "textDocument/hover": {
const document = documents.get(params.textDocument.uri);
const word = document ? wordAt(document.text, params.position)?.word : undefined;
const apiHover = word ? apiCallHover(document.text, word) : undefined;
const apiHover = word && isApiReferenceAt(document.text, offsetAt(document.text, params.position)) ? apiCallHover(document.text, word) : undefined;
if (apiHover) {
result(message.id, { contents: apiHover });
break;