Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

VS Code extension: clickable file links in chat drop the :line suffix, never jump to the line

オープン 初心者向け
#4,398 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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:

  1. Webview — apps/vscode/webview-ui/src/lib/text-enrichment.ts

    The 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, only src/foo.php becomes the link target and :27 remains plain text. The path handed to bridge.openFile() never contains a line.

  2. Extension host — apps/vscode/src/handlers/file.handler.ts

    openFile opens 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 :line suffix reached it, resolveExistingWorkspaceFile would fail to stat foo.php:27, and no selection is passed to vscode.open.

Both snippets above are from main as of today, so the bug is still present upstream.

What steps can reproduce the bug?
  1. Open a workspace in the VS Code extension.
  2. 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 as path:line).
  3. Click the rendered link.
  4. 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MoonshotAI/kimi-code のほかの issue

MoonshotAI/kimi-code の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。