anomalyco / anomalyco/opencode

Single-line file selection doesn't expand to enclosing symbol (off-by-one)

Open
#42,887 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 16, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Referencing a file with a single-line selection (startLine === endLine) should expand the read range to the enclosing symbol via documentSymbol. The check in packages/opencode/src/session/prompt.ts compares
.start.line (LSP 0-based) against start (1-based selection), so it never matches. The agent reads only the single selected line instead of the whole symbol.

Plugins

None

OpenCode version

dev

Steps to reproduce
  1. Attach a file with a single-line selection placed on a function/class definition.
  2. The agent reads only that one line instead of the enclosing symbol.
Operating System

Windows 11

Terminal

Windows Terminal

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.