fix(opencode): expand single-line selection to enclosing LSP symbol - #42888
Open
icyaaaww wants to merge 2 commits into
Open
fix(opencode): expand single-line selection to enclosing LSP symbol#42888icyaaaww wants to merge 2 commits into
icyaaaww wants to merge 2 commits into
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #42887
Type of change
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