Skip to content

Replace brace matching with property-argument highlighting#16

Closed
willibrandon wants to merge 2 commits intomainfrom
feature/property-argument-highlighting
Closed

Replace brace matching with property-argument highlighting#16
willibrandon wants to merge 2 commits intomainfrom
feature/property-argument-highlighting

Conversation

@willibrandon
Copy link
Owner

Description

The extension provided brace matching that only highlighted matching braces { and } when the cursor was positioned on them. This implementation replaces it with property-argument highlighting that visually connects template properties with their corresponding arguments, matching the behavior already implemented in the VS Code version of the extension.

Root cause: Brace matching was limited - it only showed brace pairs without indicating the relationship between template properties and their argument values. Users couldn't easily see which argument corresponded to which property in complex multi-line Serilog calls.

Solution:

  • Implemented PropertyArgumentHighlighter that tracks cursor position and highlights both property and argument simultaneously
  • Added multi-line template support including verbatim strings, raw strings, and LogError with exception parameters
  • Fixed navigation provider to use actual cursor position instead of range midpoint (fixes bug where all properties showed "Navigate to 'UserId' argument")
  • Added ESC key dismissal that temporarily hides highlights until cursor moves
  • Removed all brace matching code (SerilogBraceMatcher, SerilogBraceMatchProvider, and related classes)
  • Added test coverage for property-argument highlighting scenarios

Key Behaviors

  • When cursor is on a property like {UserId} in the template, both the property (including braces) and its corresponding argument are highlighted
  • When cursor is on an argument, both the argument and its corresponding property in the template are highlighted
  • Press ESC to temporarily dismiss highlights; they return when cursor moves
  • Works across multi-line templates in verbatim and raw strings
  • Handles LogError with exception parameter correctly (adjusts argument indices)

Testing

  • Added tests covering single-line, multi-line, positional, and edge cases
  • Verified navigation now shows correct property names instead of always showing first property
  • Tested ESC dismissal and re-activation on cursor movement

Closes #15

Implements property-argument connection highlighting to match VS Code extension behavior.
When cursor is on a template property or argument, both are highlighted visually.
Includes ESC dismissal, multi-line support, and navigation improvements.

- Remove all brace matching code and tests
- Add PropertyArgumentHighlighter with multi-line template support
- Fix navigation to use cursor position instead of range midpoint
- Update documentation to describe new feature
- Add tests for property-argument highlighting

Closes #15
@willibrandon willibrandon self-assigned this Sep 21, 2025
@willibrandon willibrandon added documentation Improvements or additions to documentation enhancement New feature or request visual-studio Visual Studio extension functionality and integration labels Sep 21, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the extension's brace matching functionality with property-argument highlighting to better match VS Code behavior. Instead of just highlighting matching braces, the extension now visually connects template properties with their corresponding arguments, making it easier to understand which argument corresponds to which property in complex multi-line Serilog calls.

  • Replaced brace matching with property-argument highlighting that connects template properties to their values
  • Fixed navigation provider to use actual cursor position instead of range midpoint
  • Added comprehensive ESC key dismissal support for temporarily hiding highlights

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
SerilogSyntax/Tagging/SerilogBraceMatcher.cs Removed entire brace matching implementation
SerilogSyntax/Tagging/PropertyArgumentHighlighter.cs Added new property-argument highlighter with multi-line support
SerilogSyntax/Tagging/PropertyArgumentHighlightState.cs Added state management for highlights with ESC dismissal
SerilogSyntax/Navigation/SerilogNavigationProvider.cs Fixed to use actual cursor position instead of range midpoint
SerilogSyntax/Classification/SerilogClassificationFormats.cs Updated format definition for property-argument highlighting
SerilogSyntax.Tests/Tagging/PropertyArgumentHighlighterTests.cs Added comprehensive test coverage for new highlighting
Comments suppressed due to low confidence (1)

SerilogSyntax/Tagging/PropertyArgumentHighlighter.cs:1

  • [nitpick] The class is declared with primary constructor syntax but later has a separate constructor implementation. This is inconsistent - either use primary constructor parameters consistently or stick to traditional constructor implementation.
using Microsoft.VisualStudio.Text;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Remove unused textBuffer parameter from SerilogSuggestedActionsSource
- Remove unused hasExceptionParameter from FindArgumentAtPosition
- Remove unused foundComma variable in template extraction
@willibrandon willibrandon deleted the feature/property-argument-highlighting branch September 21, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request visual-studio Visual Studio extension functionality and integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add property-argument highlighting

1 participant