Skip to content

fix(opencode): expand single-line selection to enclosing LSP symbol - #42888

Open
icyaaaww wants to merge 2 commits into
anomalyco:devfrom
icyaaaww:fix/lsp-symbol-expand-off-by-one
Open

fix(opencode): expand single-line selection to enclosing LSP symbol#42888
icyaaaww wants to merge 2 commits into
anomalyco:devfrom
icyaaaww:fix/lsp-symbol-expand-off-by-one

Conversation

@icyaaaww

@icyaaaww icyaaaww commented Aug 16, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42887

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Single-line file selection (startLine === endLine) was never expanded to its enclosing symbol. The check compared
.start.line (LSP 0-based) against start (1-based, parsed from the ?start= query param), so it never matched. The
?.start?.line && guard also skipped symbols on LSP line 0.

Convert the LSP line to 1-based before comparing and assigning, keeping start/end 1-based for the Read tool offset/limit math.

How did you verify your code works?

Traced the index conventions: start feeds the Read tool offset, which is 1-based ( ool/read.ts does opts.offset - 1), while LSP documentSymbol ranges are 0-based (lsp/diagnostic.ts does
ange.start.line + 1 for display). The old comparison mixed the two and could never match; the fix converts to 1-based before comparing.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 16, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant