Fix multi-line Serilog template navigation position calculation#14
Merged
willibrandon merged 2 commits intomainfrom Sep 9, 2025
Merged
Fix multi-line Serilog template navigation position calculation#14willibrandon merged 2 commits intomainfrom
willibrandon merged 2 commits intomainfrom
Conversation
- Fix template detection for multi-line verbatim and raw string literals
- Correct argument position calculation by starting after comma delimiter
- Add multi-line navigation test coverage
- Handle template end position calculation for proper argument parsing
Fixes navigation from template properties to arguments when Serilog calls span multiple lines, including verbatim strings (@"...") and raw string literals ("""...""").
There was a problem hiding this comment.
Pull Request Overview
This PR fixes multi-line Serilog template navigation position calculation issues that caused incorrect argument highlighting. The navigation would appear for some properties but select the wrong corresponding arguments due to whitespace and position offset errors in multi-line string templates.
Key changes include:
- Enhanced multi-line template detection to handle cursors positioned on the first line of multi-line templates
- Fixed template end position calculation to correctly identify where arguments start
- Improved argument parsing to handle comma delimiters properly in multi-line method calls
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| SerilogNavigationProvider.cs | Core navigation logic with multi-line template detection, position calculation fixes, and argument parsing improvements |
| SerilogClassifier.cs | Added multi-line Serilog call detection to support classification across multiple lines |
| SerilogNavigationProviderTests.cs | Comprehensive test coverage for multi-line scenarios including verbatim strings, raw string literals, and complex formatting |
| SerilogClassifierTests.cs | Added test for multi-line LogError classification behavior |
| ExampleService.cs | Added example of multi-line LogError call for testing purposes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Fix template end position consistency across string types - Extract repeated commaIndex + 1 calculation into ParseArgumentsAfterComma helper - Make ArgumentStart/ArgumentLength properties internal for better encapsulation
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.
Description
Multi-line navigation in the Serilog extension worked but highlighted incorrect arguments due to position calculation errors. Navigation would appear for some properties but select the wrong corresponding arguments because of whitespace and position offset issues in multi-line string templates.
Root cause: Three position calculation issues were causing multi-line navigation failures:
Solution:
Type of change
Checklist
.\scripts\test.ps1)Additional notes
Fixes #11