VS Code extension: clickable file links in chat drop the :line suffix, never jump to the line
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, vscode
- 領域
- desktop-dev
調査の方向性
apps/vscode/webview-ui/src/lib/text-enrichment.ts で始めて、FILE_PATH regex を更新し、:line サフィックスを捕捉して存在チェックのために削除する。次に apps/vscode/src/handlers/file.handler.ts を編集し、openFile がサフィックスを解析して selection を vscode.open に渡すようにする。Done は、path:line リンクをクリックするとその行のファイルが開くことを意味する。
索引モデルが issue の本文から書いたものです。
説明
What version of Kimi Code is running?
VS Code extension moonshot-ai.kimi-code 0.8.3 (also reproduced on current main source, see below).
What platform is your computer?
Linux x86_64 — VSCodium, remote server workspace.
What issue are you seeing?
File paths with a :line suffix in assistant chat output — the format the CLI itself is instructed to emit for code locations (path/to/file.ts:42) — render as clickable links, but clicking opens the file at whatever position it was last viewed, not at the referenced line. The line number is silently dropped in two places:
-
Webview —
apps/vscode/webview-ui/src/lib/text-enrichment.tsThe file-path detection regex stops at the file extension and never captures the line suffix:
const FILE_PATH = /(?:@|\.\/)?(?:[a-zA-Z_][\w-]*\/)*[a-zA-Z_][\w-]*\.[a-zA-Z0-9]+/;So for
src/foo.php:27, onlysrc/foo.phpbecomes the link target and:27remains plain text. Thepathhanded tobridge.openFile()never contains a line. -
Extension host —
apps/vscode/src/handlers/file.handler.tsopenFileopens the URI without any selection:const openFile: Handler<FilePathParams, { ok: boolean }> = async ({ filePath }, ctx) => { const resolved = await resolveExistingWorkspaceFile(ctx.requireWorkDirUri(), filePath); if (resolved === undefined) return { ok: false }; await vscode.commands.executeCommand("vscode.open", resolved.uri); return { ok: true }; };Even if a
:linesuffix reached it,resolveExistingWorkspaceFilewould fail to statfoo.php:27, and noselectionis passed tovscode.open.
Both snippets above are from main as of today, so the bug is still present upstream.
What steps can reproduce the bug?
- Open a workspace in the VS Code extension.
- Have the assistant output a reference like
src/components/ChatMessage.tsx:120(this format is pervasive — CLI system guidance tells the model to cite code locations aspath:line). - Click the rendered link.
- The file opens, but the cursor/view does not go to line 120 — it lands wherever the file was last open.
What is the expected behavior?
Clicking path/to/file.ts:42 opens the file with the cursor on line 42 (and ideally path:42:7 also honors the column) — the behavior other coding-agent extensions and VS Code's own Quick Open (Ctrl+P) provide for the same syntax.
Suggested fix
Minimal, backwards-compatible (paths without a suffix behave exactly as before):
webview-ui/src/lib/text-enrichment.ts
// capture an optional :line or :line:col suffix
const FILE_PATH = /(?:@|\.\/)?(?:[a-zA-Z_][\w-]*\/)*[a-zA-Z_][\w-]*\.[a-zA-Z0-9]+(?::\d+(?::\d+)?)?/;
const LINE_SUFFIX = /:\d+(?::\d+)?$/;
// extractPaths(): strip the suffix so the existence check hits the real file
seen.add(normalizePath(m[0]).replace(LINE_SUFFIX, ""));
// parseSegments(): look up existence on the stripped path, keep the suffix in `path`
const path = normalizePath(fileMatch);
segments.push(fileExistsMap[path.replace(LINE_SUFFIX, "")]
? { type: "file", value: fileMatch, path }
: { type: "text", value: fileMatch });
src/handlers/file.handler.ts
const openFile: Handler<FilePathParams, { ok: boolean }> = async ({ filePath }, ctx) => {
const lineMatch = /:(\d+)(?::(\d+))?$/.exec(filePath);
const cleanPath = lineMatch ? filePath.slice(0, lineMatch.index) : filePath;
const resolved = await resolveExistingWorkspaceFile(ctx.requireWorkDirUri(), cleanPath);
if (resolved === undefined) return { ok: false };
const options = lineMatch
? { selection: new vscode.Range(Number(lineMatch[1]) - 1, (Number(lineMatch[2]) || 1) - 1, Number(lineMatch[1]) - 1, (Number(lineMatch[2]) || 1) - 1) }
: {};
await vscode.commands.executeCommand("vscode.open", resolved.uri, options);
return { ok: true };
};
I have this running locally as a patch against the 0.8.3 dist bundles; path:line links then jump to the exact line. Related: #2194 (markdown-syntax file links not clickable at all) — fixing the openFile side would help both.
- 主要言語
- TypeScript
- スター
- 8k
- フォーク
- 1.3k
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 115
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MoonshotAI/kimi-code のほかの issue
-
[Bug] vis reports legacy tool-triggered swarm sessions as active対応中かも @louisss1016 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
MoonshotAI/kimi-code#4395 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
MoonshotAI/kimi-code#4392 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
MoonshotAI/kimi-code#4381 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
MoonshotAI/kimi-code#4369 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
MoonshotAI/kimi-code#4368 ·
メンテナーはふだん 1 日以内に返信
MoonshotAI/kimi-code の issue をすべて見る
似ている issue
-
ready
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
wheresrhys/totf#1214 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CodeChefVIT/ffcs#281 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
endora-commerce/endora-commerce#451 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
vetro-protocol/vetro-monorepo#1007 ·
メンテナーはふだん 1 日以内に返信