Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

LSP: no-op middleware onDefinition replaces the real definition handler

未关闭 适合新手
#1,139 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript, vscode

调研方向

从 apps/lsp/src/middleware.ts 和 apps/lsp/src/index.ts 开始,将 no-op 定义注册与实际 handler 以及 apps/vscode/src/lsp/client.ts:476 中的客户端入口进行比较。检查 apps/lsp/src/service/providers/definitions.ts 中相关的 provider。完成标准是:code-cell 定义仍使用虚拟文档,并且 prose 中的引用链接和标题会解析到其定义。

由索引模型根据 Issue 内容生成。

描述

Bug

In apps/lsp/src/index.ts, the server registers a real definition handler, and then calls middlewareRegister(connection), which registers a second onDefinition handler that returns null:

// apps/lsp/src/index.ts:186
connection.onDefinition(async (params, token) => {
  ...
  return mdLs?.getDefinition(document, params.position, token);
});

// apps/lsp/src/index.ts:197
middlewareRegister(connection);

// apps/lsp/src/middleware.ts:46
connection.onDefinition(async () => {
  return null;
});

In vscode-jsonrpc, registering a request handler replaces the previous one for that method, so the no-op wins. The Quarto LSP's own definition provider (apps/lsp/src/service/providers/definitions.ts) is never called.

Impact

On the client, embeddedGoToDefinitionProvider (apps/vscode/src/lsp/client.ts:476) handles positions inside code cells, and otherwise calls next(...). That falls through to the server, which now always returns null. So in .qmd prose, Go to Definition is broken for:

  • reference-style links → their [ref]: url definition
  • headers (the provider returns the header's own location)

(VS Code's built-in markdown extension may cover some of this for .md, but not for .qmd.)

History

  • 3d4ee144 (2023-02-08) added the no-op onDefinition to enable client middleware for code cells.
  • 21e441ed (2023-05-21) consolidated the no-ops into middleware.ts.
  • 07129a6a (2023-05-22), "integrate quarto lsp w/ mdls lsp", added the real handler in index.ts. It didn't remove the no-op, which is registered afterwards.

So it looks unintentional: the no-op existed only to advertise the capability, which the real handler now does on its own.

Fix

Remove the onDefinition handler and definitionProvider: true from middleware.ts. index.ts already advertises definitionProvider: true and registers the real handler, and client middleware still intercepts it. Then check that Go to Definition works both inside code cells (via the virtual doc) and on a reference link / header in prose.

It's worth checking the other no-ops in middleware.ts for the same pattern. Right now only definition has a real handler too.

Found during the dependency-upgrade research.

主要语言
TypeScript
星标
655
派生
64
平均合并
20 小时 53 分钟
30 天内合并 PR
46

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quarto-dev/quarto 的其他 Issue

查看 quarto-dev/quarto 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。