fix: correct Show in Source navigation (#line offset + unquoted filenames)#44
Merged
Conversation
GitMensch
reviewed
Apr 20, 2026
| } | ||
|
|
||
| const targetLine = Math.max(0, directive.sourceLine - 1); // convert to 0-based | ||
| const offset = cursorLine - directive.directiveLine; // lines between directive and cursor |
Contributor
There was a problem hiding this comment.
Is that correct? I think yes, but the later use of the offset should possibly have another + 1:
goes to
note that #line 6287 "../../cobc/parser.y" says that the next line is line 6287;
cursor line (6290) - directive line (6287) = 3 (+1 --> 4 if considered from the #line itself), but the position is only 3 lines below the #line .
Apart from that the feature works fine.
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.
Type of change
What does this PR do?
showInSourcejumping to the wrong line when the cursor is below a#linedirective — now applies the correct offsetsourceLine + (cursorLine − directiveLine)#linedetection not matching unquoted filenames (#line 28 parser.ywithout quotes)client/src/lineDirectiveUtils.tsfor testability (no VS Code mock needed)Closes
Closes #29 #27 (comment by @GitMensch)
Changes
client/src/lineDirectiveUtils.ts— new module:isGeneratedFile,LineDirective,findNearestLineDirectiveclient/src/lineDirectiveNavigation.ts— imports from utils, applies offset formulatests/test-line-directive.ts— 26 assertions (quoted, unquoted, edge cases)How to test manually
TS_NODE_PROJECT=tsconfig.base.json npx ts-node tests/test-line-directive.ts→ 26 passed, 0 failednpm run compile→ no errors#line M→ navigates to lineM + Nin source#line N filename.y→ directive detected and navigation works#linedirectives → warning message shownChecklist
npm run compilepasses with no new errorsnpx ts-node ...)